51nod 1057 N的阶乘(java)
基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题
输入N求N的阶乘的准确值。
Input
输入N(1 <= N <= 10000)
Output
输出N的阶乘
Input示例
5
Output示例
120
代码如下:
import java.util.Scanner;
import java.math.BigInteger;;
public class Bignu {
public static void main(String[] args)
{
int n;
Scanner cin = new Scanner(System.in);
n = cin.nextInt();
BigInteger num = new BigInteger("1");
for(int i = 1;i <= n;i ++)
num = num.multiply(BigInteger.valueOf(i));
System.out.println(num);
cin.close();
}
}