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;
}
}
第一次回答那個代碼只是少了一個“{”號而已,我復(fù)制過去的時候不小心。