Created
August 24, 2019 21:26
-
-
Save alexZajac/e4d222757a1095abf6f8cbdcef1e1870 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
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