首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

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

2013-01-07 
java中怎么样用递归写100的阶乘import java.math.BigIntegerpublic class Tset {public static BigIntege

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")));
}


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

热点排行