Skip to content

Instantly share code, notes, and snippets.

@hallazzang
Created April 15, 2016 10:30
Show Gist options
  • Save hallazzang/e83e607cdaad08f192c38f1f61cdb30d to your computer and use it in GitHub Desktop.
Save hallazzang/e83e607cdaad08f192c38f1f61cdb30d to your computer and use it in GitHub Desktop.
python fibonacci number generator code in less than 40 bytes
f=lambda a,b,n:f(b,a+b,n-1)if n>1else b # simple and fast
# for test
import sys
sys.setrecursionlimit(5001) # as default, it was 1000 in my computer
print(f(0,1,5000)) # 0 1 1 2 3 5 8 13 21 ...
print(f(1,1,5000)) # 1 1 2 3 5 8 13 21 34 ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment