首页 > 代码库 > N! java

N! java

 1 import java.util.*;
 2 import java.math.*;
 3 
 4 public class Num2{
 5     public static void main(String args[]){
 6         BigInteger s;
 7         int n;
 8         Scanner cin = new Scanner(System.in);
 9         while(cin.hasNext()){
10             n = cin.nextInt();
11             s = BigInteger.ONE;
12             for(int i = 1; i <= n; i++){
13                 s = s.multiply(BigInteger.valueOf(i));
14             }
15             System.out.println(s);
16         }
17     }
18 }

 

N! java