This is a simple Python generator for Fibonacci numbers.
This file contains hidden or 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 |