CodechefMay 05, 2025

Small factorials

Hazrat Ali

Codechef

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!

Note: For larger numbers, their factorial can overflows any available numeric data type in C.

Sample 1:

Input
 
4
1
2
5
3
 
Output
 
1
2
120
6

Solution

m = int(input())
for i in range(m):
    fact = 1
    number = int(input())
    for j in range(1,number+1):
        fact *= j

    print(fact)




Comments