why wrong answer of factorial ?

check my code at http://www.codechef.com/viewsolution/3266056
Of the problem http://www.codechef.com/problems/FCTRL2

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