Skip to content

Instantly share code, notes, and snippets.

@rootmos

rootmos/fib.py Secret

Last active Jun 6, 2017
Embed
What would you like to do?
#!/usr/bin/env python
def fib(n):
if n <= 2:
return 1
else:
return fib(n-1) + fib(n-2)
print fib(45)
# > /usr/bin/time ./fib.py
# 1134903170
# 226.28user 0.03system 3:46.92elapsed 99%CPU (0avgtext+0avgdata 6848maxresident)k
# 0inputs+0outputs (0major+928minor)pagefaults 0swaps
# > /usr/bin/time pypy fib.py
# 1134903170
# 22.31user 0.00system 0:22.33elapsed 99%CPU (0avgtext+0avgdata 79600maxresident)k
# 0inputs+0outputs (0major+10265minor)pagefaults 0swaps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment