描述
求10000以内n的阶乘。
输入
只有一行输入,整数n(0<=n<=10000)。
输出
一行,即n!的值。
样例输入
100
样例输出
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
解法:
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
BigInteger a=new BigInteger("1");
for(int i=1;i<=n;i++) {
BigInteger b=new BigInteger(String.valueOf(i));
a=a.multiply(b);
}
System.out.println(a);
}
}