My code is:
import java.math.BigInteger;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner ob = new Scanner(System.in);
int t,n;
t = ob.nextInt();
for (int i = 1; i <= t; i++) {
n = ob.nextInt();
System.out.println(Xuly(n));
}
ob.close();
}
public static BigInteger Xuly(int n){
if (n ==0){
return BigInteger.ONE;
}
BigInteger result = BigInteger.ONE;
for (int i = 1; i <= n; i++) {
result = result.multiply(BigInteger.valueOf(i));
}
return result;
}
}
Why the result is : time limit exceeded??
why?