Skip to content

Instantly share code, notes, and snippets.

@ChrisPenner
Last active June 8, 2023 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ChrisPenner/c0b3f4feb054daa2f6370d2e9961d6d3 to your computer and use it in GitHub Desktop.
Save ChrisPenner/c0b3f4feb054daa2f6370d2e9961d6d3 to your computer and use it in GitHub Desktop.
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)
Copy link

ghost commented Dec 24, 2017

I think line 6 should be return accumulator , you can pull in my fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment