Skip to content

Commit 79fad40

Browse files
factorial using recursion
1 parent c44b24c commit 79fad40

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

factorial.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Python program to calculate the factorial of a number using recursion
2+
def fact(n):
3+
if n<=1:
4+
return 1
5+
return n * fact(n-1)
6+
7+
if __name__ == '__main__':
8+
num = int(input("Please Enter the Number: "))
9+
f = fact(num)
10+
print(f"The Factorial of {num} is {f}")

0 commit comments

Comments
 (0)