Small Factorial – CodeChef Solution

What’s up coders, today we are going to solve Small Factorial CodeChef Solution whose Problem code is FLOW018.

Small Factorials - CodeChef Solution

Contents

Problem

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

Solution – Small Factorial – CodeChef Solution

Python 3

#Solution provided by Sloth Coders 
def factorial(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return n * factorial(n - 1)
n = int(input())
for i in range(n):
    num = int(input())
    print(factorial(num))

Disclaimer: The above Problem (Small Factorial) is generated by CodeChef but the Solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.

Leave a Comment

Your email address will not be published.