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
Zeljko Markovic: 2014-03-15 23:27:43

Can you output in form of an array of digits(output one digit at a time) for every example? Also, why do i get an error on this line:
vlnum () : digit {0} {}
where vlnum is the name of a structure? the code works perfectly in Code::Blocks , and compiles with no problem. please help :)

shubham sharma: 2014-03-09 12:41:59

my code is giving upto 200! correctly on my computer, but the judge is giving wrong answer, any ideas?

Last edit: 2014-03-09 12:43:20
Herman: 2014-03-05 03:42:25

really nice problem to solve using C or some other language without bignum or biginteger :)

Nick C: 2014-02-26 23:06:40

@Mitch Schwartz, I did in fact mean <=100. Also I gave ideone a whirl, output was correct there as well.

Mitch Schwartz: 2014-02-19 19:09:30

@Nick C: Have you tested on ideone? Since ideone uses the same engine as SPOJ, you can prevent certain issues like forgetting to change "%I64d" -> "%lld", or assuming "int" is 64-bit instead of 32-bit. You can also try the forum for help with debugging.

Edit: And I'm assuming you meant "less than or equal to 100" instead of "less than 100". :p

Last edit: 2014-02-19 19:36:38
Nick C: 2014-02-19 18:18:38

I've tested my program for all values less than 100 and got them all correct. However for some reason on spoj I'm getting a WA.

TCony: 2014-02-19 07:18:51

The point of this problem is large number handling. uint32 is not enough. The easiest solutions would be using Java\Ruby, which has native BigInteger\BigNum

shaleen bakshi: 2014-02-18 19:09:20

how do i deal with segmentation fault ?

appy: 2014-01-16 17:32:04

is dere a whitespaces before the output and the input ????........i m gettng WA fr a simple question

amit_gh: 2014-01-05 21:30:32

my answer is taking more than 2000bytes. How to overcome that


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