Last active
June 8, 2023 23:55
-
-
Save ChrisPenner/c0b3f4feb054daa2f6370d2e9961d6d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial(n): | |
if n == 0: return 1 | |
else: return factorial(n-1) * n | |
def tail_factorial(n, accumulator=1): | |
if n == 0: return accumulator | |
else: return tail_factorial(n-1, accumulator * n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think line 6 should be
return accumulator
, you can pull in my fix