Skip to content

Instantly share code, notes, and snippets.

@ZhouYang1993
Last active November 22, 2020 23:41
Show Gist options
  • Save ZhouYang1993/edabfa57de69ba6ca8ce1bb2a9edb2a9 to your computer and use it in GitHub Desktop.
Save ZhouYang1993/edabfa57de69ba6ca8ce1bb2a9edb2a9 to your computer and use it in GitHub Desktop.
medium 1
def factorial(n):
if n == 1:
return 1
return factorial(n - 1) * n
print(factorial(4))
def tailRecursionFactorial(n, acc):
if n == 1:
return acc
return tailRecursionFactorial(n - 1, acc * n)
print(tailRecursionFactorial(4,1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment