hey @dharmesh95
Try running your code for input
1
100
About constraints:
Input An integer t, 1<=t<=100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1<=n<=100.
So that mean your code should be able to calculate maximum of 100 factorial and factorial of 100 is
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000L
which cannot be stored in integer or floating point datatypes in c or c++, So you have to use array to store the number.
Now how to do that ?
For this problem check this link: discuss.codechef.com/questions/7349/computing-factorials-of-a-huge-number-in-cc-a-tutorial
Hope you understood…!