import java.math.BigInteger;
public class TestYiBai {
public static void main(String[] args) {
System.out.println(new TestYiBai().big(BigInteger.valueOf(100)).toString());
}
public BigInteger big(BigInteger b){
if(b.equals(BigInteger.valueOf(1L))){
return BigInteger.valueOf(1L);
}else{
return (b.multiply(big(b.subtract(BigInteger.valueOf(1L)))));
}
}
}
本文介绍了一个使用Java BigInteger类实现递归算法的例子。该算法通过递归调用计算一个数的阶乘,展示了BigInteger处理大整数的优势。文章适合对递归和大整数运算感兴趣的读者。

被折叠的 条评论
为什么被折叠?



