Skip to content

Instantly share code, notes, and snippets.

@sebdah
Last active July 13, 2021 09:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sebdah/7d33894acd9d55412e1f to your computer and use it in GitHub Desktop.
Save sebdah/7d33894acd9d55412e1f to your computer and use it in GitHub Desktop.
Fibonacci generator in Python
def fibonacci():
""" Generator yielding Fibonacci numbers
:returns: int -- Fibonacci number as an integer
"""
x, y = 0, 1
while True:
yield x
x, y = y, x + y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment