题目链接
Problem Description
Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!
Input
One N in one line, process to the end of file.
Output
For each N, output N! in one line.
Sample Input
1
2
3
Sample Output
1
2
6
解题思路:
Java大数模板
import java.math.BigInteger;
import java.util.Scanner;
public class Main {//类名必须是Main
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int a,i;
BigInteger sum;
while(in.hasNext()){//处理到文件末尾,使用in.hasNext(),切记!!
sum = BigInteger.ONE;
a = in.nextInt();
for(i = 1;i <= a;i++){
sum = sum.multiply(BigInteger.valueOf(i));
}
System.out.println(sum);
}
}
}