I am trying to solve the CodeChef problem "Small factorials". The task is to calculate the factorial of given numbers. I have the following code, which I have checked so many times. For me it gives right output, but when I try to upload it to CodeChef it gives error Wrong Answer.
import java.util.Scanner;
class SmallFactorial {
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
int iterations = sc.nextInt();
int[] myArray = new int[iterations];
int result = 1;
for(int b = 0; b < iterations; b++) {
int n = sc.nextInt();
if (n >= 1 && n <= 100) {
for (int i = 1; i <= n; i++) {
result = result * i;
}
myArray[b] = result;
result = 1;
}
}
for(int z = 0; z < myArray.length; z++){
System.out.println(myArray[z]);
}
sc.close();
}
}