From bf628bf35306e32903bba92aa2d79faacec337ba Mon Sep 17 00:00:00 2001 From: alyanrndh <56344623+alyanrndh@users.noreply.github.com> Date: Thu, 10 Oct 2019 22:59:50 +0700 Subject: [PATCH] update the factorial --- calc_main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/calc_main.py b/calc_main.py index 0de8c76..b1b1682 100644 --- a/calc_main.py +++ b/calc_main.py @@ -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() @@ -61,4 +71,4 @@ def factorial(): factorial() else: print("wrong input") - exit(0) \ No newline at end of file + exit(0)