ITeye博客

java中怎么样用递归写100的阶乘

haiyang08101 · 2010-11-30 16:10 · java · 编程语言 · Java · Markdown

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

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。