Last active
July 13, 2021 09:33
-
-
Save sebdah/7d33894acd9d55412e1f to your computer and use it in GitHub Desktop.
Fibonacci generator in Python
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 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