From f1a2ce745cbba310770bca0b04f2d99a0e01a155 Mon Sep 17 00:00:00 2001 From: Vibhanshu Singh <135852806+singhvibhanshu@users.noreply.github.com> Date: Sat, 19 Oct 2024 13:18:11 +0530 Subject: [PATCH 1/2] Create factorial.py Fixes #12142 --- recursion/factorial.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 recursion/factorial.py diff --git a/recursion/factorial.py b/recursion/factorial.py new file mode 100644 index 000000000000..54c5cbfeacf7 --- /dev/null +++ b/recursion/factorial.py @@ -0,0 +1,8 @@ +def factorial(n): + if n == 0 or n == 1: + return 1 + else: + return n * factorial(n - 1) + +# Example +print(factorial(4)) From a09e58ad5b81074d1981b4570c3b5128af484794 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 19 Oct 2024 07:50:51 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- recursion/factorial.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recursion/factorial.py b/recursion/factorial.py index 54c5cbfeacf7..57a5b53f4c8c 100644 --- a/recursion/factorial.py +++ b/recursion/factorial.py @@ -4,5 +4,6 @@ def factorial(n): else: return n * factorial(n - 1) + # Example print(factorial(4))