读书人

java中如何样用递归写100的阶乘

发布时间: 2013-01-07 10:02:25 作者: rapoo

java中怎么样用递归写100的阶乘
import java.math.BigInteger;

public class Tset {
public static BigInteger factorial(BigInteger num) {
if (num.equals(BigInteger.ONE) || num.equals(BigInteger.ZERO))
return BigInteger.ONE;
return num.multiply((factorial(num.subtract(BigInteger.ONE ))));

}

public static void main(String args[]) {
System.out.println(factorial(new BigInteger("100")));
}


}
//直接复制上去就可以........!

读书人网 >编程

热点推荐