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

Sample input:
4
1
2
5
3

Sample output:

1
2
120
6

hide comments
faiz: 2015-05-04 19:51:28

very big integer like 100! can be stored in cpp_int in boost::multiprecision in c++

subbu: 2015-05-03 13:24:08

I used double to store the value of integer and removed the decimal points. Works fine on Ideone but wrong answer. Can anyone help?

polarisalo: 2015-04-30 12:08:57

Now I find that python is good!

elpmaxe: 2015-04-27 04:08:37

I submitted two programs, one assuming 0!=1 and one assuming 0!=0. Only the one assuming 0!=0 passed, which is wrong because 0!=1.
Also, this is outside of the test case constraints. It explicitly states,

"a single integer n, 1<=n<=100"
so zero should not exist as a test case

Last edit: 2015-04-27 04:35:04
Mani: 2015-04-14 08:54:51

Hi, I wrote java code which is giving correct values but in i64 representation(Eg:2.43290200817664E18) and while submitting it is showing as wrong answer.Can any one please guide me?

sandy: 2015-04-01 17:38:08

remember to put \n after printing the ans of any testcase...it costs me two WA....

Tony T.: 2015-03-16 23:50:14

thought this was pretty difficult, even if i read up on how this problem should be tackled

John Jost: 2015-03-15 18:18:09

I think the 2000B limit is frustrating and arbitrary. I was basically forced to take my algorithm, remove all the whitespace, and rename all my variables to single char names. Ok, I am now under your size limit but nothing about my program has changed except it's an unreadable mess now.

Tista Saha: 2015-03-05 18:29:48

my program is running well in gcc and is showing segmentation fault here.can anyone help?

Rishabh Prasad: 2015-02-20 20:32:09

Hello everyone.. All coders who are facing problems to store such a large numbers i want to give a hint.. Use arrays to store number...


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