small factorials

The code runs fine on my compiler and other IDE’s present online,but in codechef it gives me an error,i don’t know where the problem lies,can anyone help me out in this?

Code:

#include<stdio.h>
 
int main() {
long long n,t;
scanf("%lld",&t);
while(t--){
scanf("%lld",&n);
int f=1;
while(n>0){
f=f*n;
n--;
}
printf("%lld",f);
}
return 0;
}

I think you are getting WA. It should be, because factorial of n would be very large, which cannot be stored in an int data type (even unsigned long long int will fail to store the result of factorial of n where n > 20). You must use an array to store the digits of the result.

Also, you have declared ‘f’ as int, but you are trying to print it as long long int, which should give a compile time warning (if not error).