why wrong answer of factorial ?

check my code at CodeChef: Practical coding for everyone
Of the problem FCTRL2 Problem - CodeChef

i think u r not initializing ‘m’ for each test case …

That is why ur ans for
5
10
2
3
1
5
comes out to be
3628800
0000002
0000006
0000001
0000120