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
Viraj Kulkarni: 2011-06-30 17:59:58

This was silly! I kept getting a wrong answer even though I checked my code and my answers multiple times. I had missed the '\n' at the end of my answer in printf!

Matej Badin: 2011-06-12 13:46:51

:( Toogle editor shows wrong number of characters, overflow with 1900 characters

shivaraj Challapalli: 2011-06-06 01:45:24

In my terminal im getting the answer accurately but here it is given as wrong answer ????

Piotr KÄ…kol: 2011-05-13 12:55:23

@Albert Gevorgyan - Check all factorials 1..100 on Wolfram Alpha or ask on forum.

albertg: 2011-05-13 05:14:12

I'm getting the same answer(9332621544394415268169923885626670049071596826438162146859296389521759999322991560 8941463976156518286253697920827223758251185210916864000000000000000000000000 ) for 100, but /i getting WA. HELP!!!

albertg: 2011-05-13 04:08:42

Thank you, ycxw.

Sarwesh Shah: 2011-04-30 14:21:13

how to increase the digits of precision in the answer? i get precise digits upto 16 places. HELP!!

Last edit: 2011-04-30 14:22:24
anonymous: 2011-04-30 13:22:00

100! = 9332621544394415268169923885626670049071596826438162146859296389521759999322991560 8941463976156518286253697920827223758251185210916864000000000000000000000000
Just in case someone wants to check :)

Last edit: 2011-04-30 13:22:44
ziaur rahman: 2011-04-19 09:25:18

I am also getting WA, using C++ , any advice?

MF: 2011-03-19 19:56:21

The only way is to create a minimal arbitrary-size arithmetic functions in order to handle such great outputs ( unless your language supported ASA ). Think about it: 1<=n<=100
15! = 1307674368000
Can your integers hold such a value?
How about 20! ? 30! ? 40! ? 100! ? I hope you get my point.

Last edit: 2011-03-19 20:00:26

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