Created
July 25, 2015 20:03
-
-
Save amckinley/443395cdfb030908b858 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def fib(n): | |
if n == 0: | |
return 0, 0 | |
if n == 1: | |
return 1, 0 | |
a, a_cnt = fib(n-1) | |
b, b_cnt = fib(n-2) | |
return a + b, (a_cnt + b_cnt + 2) | |
def main(): | |
for i in range(10): | |
fib_i, cnt_i = fib(i) | |
print i, fib_i, cnt_i | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment