public class Test {
public static void main(String[] args) {
int n = 6;
System.out.println(jiecheng(n));
}
public static BigInteger jiecheng (int i) {
BigInteger result = new BigInteger("1");
for (int j = 1; j <= i; j ++) {
BigInteger num = new BigInteger(String.valueOf(j));
result = result.multiply(num);
}
return result;
}是错的
public class Test {
public static void main(String[] args) {
int n = 6;
System.out.println(jiecheng(n));
}
public static Double jiecheng (int i) {
Double result = 1.0;
for (int j = 1; j <= i; j ++) {
\x09result *= j;
}
return result;
}
}
第一次回答那个代码只是少了一个“{”号而已,我复制过去的时候不小心。