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
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...

l4mbda: 2015-02-07 02:23:15

as said before a recursive function tackles this easily

subhash kumar: 2015-01-21 19:02:25

how to find currect solution of problem

Michael Scofield: 2015-01-07 13:09:48

PYTHON simply Rocksss...

Adesh Atole: 2015-01-01 18:47:07

Use java.math.BigInteger

Tanvi Singh: 2014-12-12 16:06:55

What data type to use to store factorial of numbers like 100! ?

Swapnil Borse: 2014-12-02 17:16:47

Hello everyone, saw in the comments that many are struggling with the wrong answers.The maximum number that we can store in an unsigned 32 bit integer is 2 ^ 32 - 1 and in an unsigned 64 bit integer is 2 ^ 64 - 1. Something like 100!('!' is the notation for factorial) has over 150 decimal digits. The data types mentioned earlier can store numbers having at most 9 and 19 decimal digits respectively. So make sure that you take a note of this and then try to decide your approach. Nice problem to trick the coders ;)

Asha Menezes: 2014-12-01 08:26:55

how to submit an answer for this question?
--ans(Francky)--> Please try TEST first. You'll find a submit link for your code ; a solution is provided too for this lonely problem in forum.

Last edit: 2014-12-01 15:34:48
Himgiri Garg: 2014-11-29 09:09:25

My code prints out correctly for every number between 1 and 100. Not sure what the error could be.


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