Skip to content

Commit db8e5b3

Browse files
committed
Факториал любого числа
1 parent 8dd1fec commit db8e5b3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def factorial(n):
2+
# Base case
3+
if n == 0 or n == 1:
4+
return 1
5+
6+
if n < 0:
7+
return -1
8+
# Recursive call
9+
return n * factorial(n - 1)
10+
11+
12+
print(factorial(5))

0 commit comments

Comments
 (0)