Skip to content

Commit d9013b0

Browse files
committed
SPOJ Problems
1 parent 6f5cd4b commit d9013b0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# You are asked to calculate factorials of some small positive integers.
2+
#
3+
# Input
4+
#
5+
# An integer t, 1<=t<=100, denoting the number of testcases, followed by t lines, each containing a single integer n,
6+
# 1<=n<=100.
7+
#
8+
# Output
9+
#
10+
# For each integer n given at input, display a line with the value of n!
11+
#
12+
# Example
13+
#
14+
# Sample input:
15+
# 4
16+
# 1
17+
# 2
18+
# 5
19+
# 3
20+
# Sample output:
21+
#
22+
# 1
23+
# 2
24+
# 120
25+
# 6
26+
27+
def factorial(number):
28+
if number == 0 or number == 1:
29+
return 1
30+
else:
31+
return number * factorial(number - 1)
32+
33+
testCases = int(input())
34+
for _ in range(testCases):
35+
number = int(input())
36+
print(factorial(number))

0 commit comments

Comments
 (0)