Skip to content

Commit 4a5cb73

Browse files
authored
Create factorial.py
1 parent 9bccf15 commit 4a5cb73

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

factorial.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def factorial(n):
2+
3+
# single line to find factorial
4+
return 1 if (n==1 or n==0) else n * factorial(n - 1)
5+
6+
num = int(input("Enter a number: "))
7+
print ("Factorial of",num,"is",
8+
factorial(num))

0 commit comments

Comments
 (0)