Skip to content

Instantly share code, notes, and snippets.

@zhenyi2697
Created August 8, 2013 12:09
Show Gist options
  • Select an option

  • Save zhenyi2697/6184063 to your computer and use it in GitHub Desktop.

Select an option

Save zhenyi2697/6184063 to your computer and use it in GitHub Desktop.
Python: fibonacci using yield and list comprehension
def fibonacci(max):
a, b = 0, 1
while a < max:
yield a
a, b = b, a+b
print [x for x in fibonacci(100)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment