From 5d37346b7fffde1fb61fb64eb1768642e8855d7f Mon Sep 17 00:00:00 2001 From: devanshi Date: Wed, 10 Oct 2018 21:08:43 +0530 Subject: [PATCH 1/3] Removed brackets after if --- OddOrEven.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OddOrEven.py b/OddOrEven.py index 2a7921d..4ad971c 100644 --- a/OddOrEven.py +++ b/OddOrEven.py @@ -1,5 +1,5 @@ n = int(input("Enter a number")) -if(n%2==0): +if n%2==0: print("Even number.") else: print("Odd number.") From 7f8f6b284d4aca0e42c61a6634bfc05bf90ed035 Mon Sep 17 00:00:00 2001 From: devanshi Date: Wed, 10 Oct 2018 22:17:51 +0530 Subject: [PATCH 2/3] added factorial without recursion program --- factorial.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 factorial.py diff --git a/factorial.py b/factorial.py new file mode 100644 index 0000000..e2af6fa --- /dev/null +++ b/factorial.py @@ -0,0 +1,10 @@ +n=int(input("enter a number")) +factorial=1 +if n<0: + printf("factorial does not exist") +elif n==0: + printf("factorial of 0 is 1") +else: +for i in range(1,n+1): + factorial=factorial*i + printf("factorial is ",factorial) From 581c97e3806404479ede748b7c52a1b49b91578e Mon Sep 17 00:00:00 2001 From: devanshiv123 Date: Thu, 11 Oct 2018 22:41:19 +0530 Subject: [PATCH 3/3] added factorial with recursion program --- recursion_factorial.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 recursion_factorial.py diff --git a/recursion_factorial.py b/recursion_factorial.py new file mode 100644 index 0000000..3b4fff9 --- /dev/null +++ b/recursion_factorial.py @@ -0,0 +1,9 @@ + +def calc_factorial(x): + if x==1: + return 1 + else: + return(x*calc_factorial(x-1)) +num=int(input("enter number")) +printf("factorial is ",calc_factorial(num)) +