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
nadra7: 2016-09-27 04:46:28

Don't print new line in last

farzadhallaji: 2016-09-20 17:42:48

for last input don't print new line ....

Last edit: 2016-09-20 17:43:16
ssrinet: 2016-09-14 13:21:24

most worst site after submitting right answer showing compilation error...HAckerearth is much better

hsuyaihtar: 2016-08-30 18:54:03

nitish_garg503 , the code you have written, will genearate an output after each input, thus reason of wrong answer. Store them in array and display later, it will work.

nitish_garg503: 2016-08-06 08:29:43

import java.util.*;
import java.lang.*;

class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner s = new Scanner(System.in);
int t =s.nextInt();
for(int i=0;i<t;i++)
{
int m = s.nextInt();
int p=1;
int fact= 1;
while(p<=m)
{
fact = fact * p;
p++;
}
System.out.println(fact);
System.out.println(" ");
}

}
} in java but it show wrong answer

xtaldew: 2016-07-27 16:46:12

Actually, I cant find what wrong wiith my code! :(
I already added newline or 0!=0 or 0!=1 ... but nothing change
any body give a help?

square1001: 2016-07-16 03:10:12

Source limit 2000B is so strict.
My C++ Big integer library is about 10000B.

alphastar: 2016-07-06 07:55:13

Don't do it in python or java. If you do you won't learn anything new.

shubh11: 2016-07-03 21:33:11

seriouly.........100! comes under small factorials

spartax: 2016-06-30 16:15:09

newline sucks !!


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