N! HDU

Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! 

InputOne N in one line, process to the end of file. 
OutputFor each N, output N! in one line. 
Sample Input

1
2
3

Sample Output

1
2
6
大数阶乘 java大法好+1
 1 import java.util.*;
 2 import java.math.*;
 3 public class Main {
 4  public static BigInteger TM;
 5  public static void main(String[] args){
 6   Scanner sc=new Scanner(System.in);
 7   while(sc.hasNext()){
 8    int n=sc.nextInt();
 9    TM=BigInteger.ONE;
10    for(int i=1;i<=n;i++){
11     TM=TM.multiply(BigInteger.valueOf(i));
12    }
13    System.out.println(TM);
14   }
15   
16  }
17 }
View Code
原文地址:https://www.cnblogs.com/dulute/p/7272570.html