From cc05030945b644d2d04232942f92ebc1c69c2863 Mon Sep 17 00:00:00 2001 From: gaeun917 Date: Sun, 15 Oct 2017 15:54:57 +0100 Subject: [PATCH 1/3] added factorial in simpleAddition/factorial.py --- .idea/vcs.xml | 6 ++++++ SimpleAddition/factorial.py | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 .idea/vcs.xml create mode 100644 SimpleAddition/factorial.py diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SimpleAddition/factorial.py b/SimpleAddition/factorial.py new file mode 100644 index 0000000..c22fd4c --- /dev/null +++ b/SimpleAddition/factorial.py @@ -0,0 +1,12 @@ +num = int(input("Enter a number: ")) + +factorial = 1 + +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) \ No newline at end of file From 81b309d7c85ff85856c5f4ba1910d8c428dfa55d Mon Sep 17 00:00:00 2001 From: gaeun917 Date: Sun, 15 Oct 2017 15:56:13 +0100 Subject: [PATCH 2/3] added factorial in simpleAddition/factorial.py --- SimpleAddition/factorial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimpleAddition/factorial.py b/SimpleAddition/factorial.py index c22fd4c..0f43061 100644 --- a/SimpleAddition/factorial.py +++ b/SimpleAddition/factorial.py @@ -1,6 +1,6 @@ num = int(input("Enter a number: ")) -factorial = 1 +factorial = 1 if num < 0: print("Sorry, factorial does not exist for negative numbers") From d9fb4ce819067ca632e4f373c3b161bf109e5990 Mon Sep 17 00:00:00 2001 From: gaeun917 Date: Sun, 15 Oct 2017 15:56:34 +0100 Subject: [PATCH 3/3] added factorial in simpleAddition/factorial.py --- SimpleAddition/factorial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimpleAddition/factorial.py b/SimpleAddition/factorial.py index 0f43061..c22fd4c 100644 --- a/SimpleAddition/factorial.py +++ b/SimpleAddition/factorial.py @@ -1,6 +1,6 @@ num = int(input("Enter a number: ")) -factorial = 1 +factorial = 1 if num < 0: print("Sorry, factorial does not exist for negative numbers")