Created
May 23, 2014 02:30
-
-
Save mengzhuo/01fb4460dfec4fb1cb56 to your computer and use it in GitHub Desktop.
Fib generator
This file contains 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(): | |
x, y = 0,1 | |
while True: | |
yield x | |
x, y = y,x+y | |
fibgen=fib() | |
print [fibgen.next() for x in xrange(40)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment