Created
April 15, 2016 10:30
-
-
Save hallazzang/e83e607cdaad08f192c38f1f61cdb30d to your computer and use it in GitHub Desktop.
python fibonacci number generator code in less than 40 bytes
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
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