From b72b5d0dc8f078c72e4715afa46842e53e093598 Mon Sep 17 00:00:00 2001 From: tyforv <31525814+tylerdurdenforvendetta@users.noreply.github.com> Date: Tue, 5 Mar 2019 12:08:19 -0600 Subject: [PATCH 1/2] Added factorial function to Python file --- Python/Functions.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Python/Functions.py b/Python/Functions.py index 3a2048f..646aa52 100644 --- a/Python/Functions.py +++ b/Python/Functions.py @@ -15,3 +15,12 @@ def reverseMessage(x): for i in range((len(b)-1),-1,-1): r=r+b[i]+"" return print(r) + +# A function that calculates the factorial of a number recursively + +def factorial(n): + if (n == 0): + return 1 + else: + rest = factorial(n-1) + return rest * n \ No newline at end of file From 1f85144c805dffdbd9978780e4d881bff5132df6 Mon Sep 17 00:00:00 2001 From: tyforv <31525814+tylerdurdenforvendetta@users.noreply.github.com> Date: Tue, 5 Mar 2019 12:10:43 -0600 Subject: [PATCH 2/2] Fixed a spacing issue with the python file --- Python/Functions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Python/Functions.py b/Python/Functions.py index 646aa52..7b752ec 100644 --- a/Python/Functions.py +++ b/Python/Functions.py @@ -17,7 +17,6 @@ def reverseMessage(x): return print(r) # A function that calculates the factorial of a number recursively - def factorial(n): if (n == 0): return 1