Skip to content

Instantly share code, notes, and snippets.

@springcoil
Created January 6, 2016 20:57
Show Gist options
  • Save springcoil/5c0b90b91e0d6945633f to your computer and use it in GitHub Desktop.
Save springcoil/5c0b90b91e0d6945633f to your computer and use it in GitHub Desktop.
Fibonacci fun with generators
def fib(a=1, b=1):
while True:
yield a
a, b = b, a + b
from itertools import islice
list(islice(fib(), 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment