Skip to content

Commit

Permalink
update the factorial
Browse files Browse the repository at this point in the history
  • Loading branch information
alyanrndh authored Oct 10, 2019
1 parent d6cd1ba commit bf628bf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion calc_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ def floor_division():


def factorial():
num = int(input("enter a number: "))
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is:",factorial)
return

if choice==1:
additon()
Expand All @@ -61,4 +71,4 @@ def factorial():
factorial()
else:
print("wrong input")
exit(0)
exit(0)

0 comments on commit bf628bf

Please sign in to comment.