FCTRL2 - Small factorials


You are asked to calculate factorials of some small positive integers.

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.

Output

For each integer n given at input, display a line with the value of n!

Example

Input:
4
1
2
5
3

Output:
1
2
120
6

hide comments
Michael Moerschell: 2014-07-18 19:33:46

9 lines of Python code... :) -> 0.12s

Last edit: 2014-07-18 19:34:18
Anupam Rastogi: 2014-07-03 01:18:07

Nailed it!Very Good problem.

Alex Tran: 2014-06-22 02:33:03

make a list of constants from 0 to 100 would help..
<snip>
... but the code will be too big and not accepted..

Last edit: 2022-09-17 23:11:49
Abhijeet Dubey: 2014-06-10 21:12:38

finally got it right...they call it small factorials...phew...

agaurav77: 2014-06-10 14:21:52

Phew, finally AC! My code worked for all the cases except N=100 (I don't know why). It gave the third last digit in 100! as 8 (??). Just handled that case.

Just use array of ints in C, and check your output at ideone. Your computer might give a different answer. Atleast check for n=100

Last edit: 2014-06-10 14:22:14
അഭി : 2014-05-29 04:20:16

Source limit of 2000B is so strict. I had to delete all the comments to get my code to submit

Wasim Thabraze: 2014-05-22 19:34:47

Finally AC after two TLE's!

Last edit: 2014-07-01 18:41:51
HARSH: 2014-05-22 00:18:54

Nice problem learn't how to deal with large no.

pvkcse: 2014-05-14 18:49:46

tried tried and tried with c# and finally got solution in c...really a good problem taught me how to handle big integers in c and c++ other than java...

pvkcse: 2014-05-08 19:24:03

used c# and got output in my system...but here in spoj i have got WA...don't know what the reason is...


Added by:adrian
Date:2004-05-28
Time limit:1s
Source limit:2000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All