Last active
January 15, 2017 10:43
-
-
Save Kwpolska/c7dff794429d202a9c622e669cd5d588 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
#!/usr/bin/env python3 | |
from __future__ import print_function | |
def f(n, level=0): | |
indent = level * ' ' | |
print(indent, 'start', n) | |
if n == 10202: | |
print(indent, 'return constant from', n) | |
return 4 | |
re = f(n ** 2 + 1, level + 1) | |
print(indent, 'continue', n) | |
s = 2 * n * re | |
print(indent, 's =', s) | |
print(indent, 'return from', n) | |
return s | |
f(3) | |
# start 3 | |
# start 10 | |
# start 101 | |
# start 10202 | |
# return constant from 10202 | |
# continue 101 | |
# s = 808 | |
# return from 101 | |
# continue 10 | |
# s = 16160 | |
# return from 10 | |
# continue 3 | |
# s = 96960 | |
# return from 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment