From c966f61f5a2cc7e6999fa86e2bb8e547a7ed8119 Mon Sep 17 00:00:00 2001 From: Prajwal Date: Tue, 25 Oct 2022 11:02:01 +0530 Subject: [PATCH] pthon program to find factorial --- factorial.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 factorial.py diff --git a/factorial.py b/factorial.py new file mode 100644 index 0000000..f65f3f4 --- /dev/null +++ b/factorial.py @@ -0,0 +1,13 @@ +class Solution: + def factorial(self, num): + if num == 0 or num == 1: + return 1 + else: + return num * s.factorial(num-1) # 5 * 4! + + +if __name__ == '__main__': + number = int(input("Enter number : ")) + s = Solution() + s.factorial(number) + print(f"The factorial of {number} is { s.factorial(number)}") \ No newline at end of file