Skip to content

Commit 1b405e1

Browse files
committed
Add solution for problem zhiwehu#2
1 parent 2993936 commit 1b405e1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

solutions/02.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 01.
2+
# Write a program which can compute the factorial of a given numbers.
3+
# The results should be printed in a comma-separated sequence on a single line.
4+
# Suppose the following input is supplied to the program:
5+
# 8
6+
# Then, the output should be:
7+
# 40320
8+
9+
def factorial(x):
10+
if(x == 1):
11+
return 1
12+
13+
return x * factorial(x - 1)
14+
15+
x = int(input('Type your number: '))
16+
17+
print(factorial(x))

0 commit comments

Comments
 (0)