Skip to content

Instantly share code, notes, and snippets.

@alexZajac
Created August 24, 2019 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexZajac/e4d222757a1095abf6f8cbdcef1e1870 to your computer and use it in GitHub Desktop.
Save alexZajac/e4d222757a1095abf6f8cbdcef1e1870 to your computer and use it in GitHub Desktop.
from decorpy import debug
@debug
def factorial(n, acc=1):
if n < 2:
return acc
return factorial(n-1, n*acc)
f5 = factorial(5)
## Output :
Now calling factorial(5)
Now calling factorial(4, 5)
Now calling factorial(3, 20)
Now calling factorial(2, 60)
Now calling factorial(1, 120)
Call with factorial(1, 120) -> returned 120
Call with factorial(2, 60) -> returned 120
Call with factorial(3, 20) -> returned 120
Call with factorial(4, 5) -> returned 120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment