Thanks for posting the question. It appears that you are new to Codechef so welcome to the community. I checked the code, and edited out some basic lines like -
i) There is no need for an “Input” prompt. The input will be given by the judging system and whatever you print our additionally will be marked as output. Since the output format is very strict, try and stick to that.
ii) No need to check if the test cases are within limits or not. The boundaries giving in the problem statement will always be valid. And it is the tester’s responsibility to ensure that the input is within limits.
iii) Test the code with the sample input. Once you are able to get the sample output, design your own sample cases that test boundary conditions. For example, try taking 100 factorial, or zero factorial.
In your case, the logic fails at anything more than 25, since the variable temp is an ‘int’ datatype which can hold at max data upto 2*10^9. So you need a different logic. As described here -