diff --git a/Python/Functions.py b/Python/Functions.py index 3a2048f..7b752ec 100644 --- a/Python/Functions.py +++ b/Python/Functions.py @@ -15,3 +15,11 @@ 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