Skip to content

Instantly share code, notes, and snippets.

@amckinley
Created July 25, 2015 20:03
Show Gist options
  • Save amckinley/443395cdfb030908b858 to your computer and use it in GitHub Desktop.
Save amckinley/443395cdfb030908b858 to your computer and use it in GitHub Desktop.
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