所以我正在使用BigInteger类创建一个阶乘程序.但我一直得到上述错误.
public static BigInteger fact(long n){
BigInteger result = BigInteger.ONE;
for(int i = 1; i <= n; ++i){
result = result.multiply(new BigInteger(i));
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
我已经找到了修复,它只是添加一个带有结果的空字符串.
result = result.multiply(new BigInteger(i + ""))
我的问题是,为什么我们要添加那个空字符串?
java ×1