Sphere Online Judge

SPOJ Problem Set (classical)

24. Small factorials

Problem code: FCTRL2

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

Added by:Adrian Kosowski
Date:2004-05-28
Time limit:1s
Source limit:2000B
Languages:All except: TECS

hide comments
2010-05-25 16:41:07 Lucia Antonius
what data type I should use??
2010-05-17 07:55:47 Seshadri R
@Subhajit Sadhu: The data type (int, unsigned or long long unsigned) used by you for holding the result could have been too small and an arithmetic overflow would have resulted
2010-05-14 18:32:02 Ritesh Kr. Kayal
my compiler is giving a correct output, but when i'm submitting i am getting sometimes run-time error, sometimes wrong answer.. what should i do?

Last edit: 2010-05-14 18:32:41
2010-05-06 16:58:49 Subhajit Sadhu
my own compiler is giving correct result..bt when I'm submitting in ur compiler it is giving "runtime error (SIGABRT)" wht does this imply ???
2010-04-06 11:56:58 Fahd Shariff
I submitted my bash solution, but it failed with a wrong answer! The same solution worked on CodeChef though!
2009-12-31 18:03:49 Jason Robinson
It seems that bignum is disabled for Perl. How can we provide the desired answer without it?
2009-09-21 07:40:31 小岛
Evaluating the scale of the result sometimes is important..especially for this one..
2009-09-05 15:48:30 Krzysztof Kosiński
biswajyoti das: it means you defined main() with a return type other than int and/or you are missing a 'return 0' at the end.
2009-08-31 15:07:43 Javier (dreivaj)
The problem is BigInteger
2009-08-23 11:28:51 Chris
Ruby 0.03s, if your program is too slow i suggest to take look into caching

Last edit: 2009-08-23 11:31:37
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.