Skip to content

Commit 32a050f

Browse files
authoredJul 16, 2021
Create Factorial.py
1 parent 31ba94b commit 32a050f

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+
num = int(input("Enter a number: "))
2+
factorial = 1
3+
if num < 0:
4+
print("Sorry, factorial does not exist for negative numbers")
5+
elif num == 0:
6+
print("The factorial of 0 is 1")
7+
else:
8+
for i in range(1,num + 1):
9+
factorial = factorial*i
10+
print("The factorial of",num,"is",factorial)

0 commit comments

Comments
 (0)
Please sign in to comment.