java 大数阶乘代码

import java.io.*;  
import java.math.BigInteger;  
import java.util.*;  

public class Main  
{  
	public static void main(String args[])  
	{  
		Scanner cin = new Scanner(System.in); 
		while(cin.hasNext()){
			int n = cin.nextInt();  
			BigInteger ans = BigInteger.ONE;  
			for(int i = 1; i <= n; ++i)  
				ans = ans.multiply(BigInteger.valueOf(i));  
			System.out.println(ans);  
		}  
	}
}  


你可能感兴趣的:(java,ACM,大数)