From 06d9456ac8ea820023f5f703241f70d2487cf8a7 Mon Sep 17 00:00:00 2001 From: sonam290597 <73711739+sonam290597@users.noreply.github.com> Date: Fri, 30 Oct 2020 23:48:06 +0530 Subject: [PATCH 1/2] Create Factorial of a given number in python --- Factorial of a given number in python | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Factorial of a given number in python diff --git a/Factorial of a given number in python b/Factorial of a given number in python new file mode 100644 index 0000000..3800516 --- /dev/null +++ b/Factorial of a given number in python @@ -0,0 +1,15 @@ +def recur_factorial(n): + if n == 1: + return n + else: + return n*recur_factorial(n-1) + +num = 7 + +# check if the number is negative +if num < 0: + print("Sorry, factorial does not exist for negative numbers") +elif num == 0: + print("The factorial of 0 is 1") +else: + print("The factorial of", num, "is",recur_factorial(num)) ) From 0e25250de14ab04805e79032964e1740dd96b7bb Mon Sep 17 00:00:00 2001 From: sonam290597 <73711739+sonam290597@users.noreply.github.com> Date: Fri, 30 Oct 2020 23:51:43 +0530 Subject: [PATCH 2/2] Create Factor of a given number in python --- Factor of a given number in python | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Factor of a given number in python diff --git a/Factor of a given number in python b/Factor of a given number in python new file mode 100644 index 0000000..c12ae65 --- /dev/null +++ b/Factor of a given number in python @@ -0,0 +1,9 @@ +def print_factors(x): + print("The factors of",x,"are:") + for i in range(1, x + 1): + if x % i == 0: + print(i) + +num = 320 + +print_factors(num)