1057 N的阶乘

1057 N的阶乘

基准时间限制:秒 空间限制:131072 KB 

输入NN的阶乘的准确值。

Input

输入N(1 <= N <= 10000)

Output

输出N的阶乘

Input示例

5

Output示例

120

import java.math.BigInteger;
import java.util.Scanner;
public class Main {
    static BigInteger ans(BigInteger a,int b){
        BigInteger anss=BigInteger.ONE;
        for(int i=1;i<=b;i++)
            anss=anss.multiply(new BigInteger(i+""));
        return anss;
        
    }
    

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            BigInteger a=sc.nextBigInteger();
                int b=Integer.parseInt(a+"");
            System.out.println(ans(a,b));
            
        }
        
        sc.close();

    }

}
原文地址:https://www.cnblogs.com/watchfree/p/5350707.html