Skip to content

Commit 490126b

Browse files
Create factorial.py
Fixes #12142
1 parent 03a4251 commit 490126b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

recursion/factorial.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def factorial(n):
2+
if n == 0 or n == 1:
3+
return 1
4+
else:
5+
return n * factorial(n - 1)
6+
7+
print(factorial(5)) # Example

0 commit comments

Comments
 (0)