N的阶乘 (大数据)

时间:2023-01-25 09:57:28
输入N求N的阶乘的准确值。

Input 输入N(1 <= N <= 10000) Output 输出N的阶乘 Sample Input
5
Sample Output
120
代码:
import java.math.BigInteger;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner cin = new Scanner(System.in);
        int n;
        n = cin.nextInt();
        BigInteger sum = new BigInteger("1");
        for(int i=1;i<=n;i++) {
        	sum=sum.multiply(BigInteger.valueOf(i));
        }
        System.out.println(sum);
	}
}