I wrote this very simple code for the factorials like we are taught in math class but it is still wrong for codechef. Please help!
void fact(int x){
int ans = 1;
while(x!= 0){
ans *= x;
x--;
}
printf("%d\n", ans);
}
int main(void) {
// your code goes here
int n;
scanf("%d" , &n);
while(n--){
int x;
scanf("%d", &x);
fact(x);
}
return 0;
}