我试图找到T编号的每个数n阶乘和输入由user.The约束提供的;
1 < t <= 100
1 < n <= 100
我的代码是:
import java.util.Scanner;
import java.math.BigInteger;
public class fact {
public static void main(String args[]) {
int t = 0, i = 0;
BigInteger result = BigInteger.valueOf(1);
BigInteger x1 = BigInteger.ONE;
Scanner sc = new Scanner(System.in);
t = sc.nextInt();
BigInteger a[] = new BigInteger[t];
for(i = 0; i < t; i++) {
a[i] = BigInteger.valueOf(sc.nextInt());
}
for(i = 0; i < t; i++) {
while(!a[i].equals(x1)) {
result = result.multiply(a[i]);
a[i].subtract(BigInteger.valueOf(1));
}
System.out.println(result);
result = x1;
}
}
}
我收到没有错误上面的代码它编译罚款,当我执行它只是不断让输入并打印没有输出。