日期:2014-05-20 浏览次数:20800 次
package ex14; import java.math.*; public class LargeFactorial { public static void main(String[] args) { // TODO 自动生成方法存根 System.out.println("50! is\n"+factorial(50)); } public static BigInteger factorial(long n){ BigInteger result=BigInteger.ONE; for(int i=1;i<=n;i++) result=result.multiply(new BigInteger(i+""));//这里的i+""不是很理解 return result; } }
package ex14; import java.math.*; public class LargeFactorial { public static void main(String[] args) { // TODO 自动生成方法存根 System.out.println("50! is\n"+factorial(50)); } public static BigInteger factorial(long n){ BigInteger result=BigInteger.ONE; for(int i=1;i<=n;i++) result=result.multiply(new BigInteger("i")); return result; } }