Created
January 5, 2018 04:33
-
-
Save hoangddt/76db0c1078f41ea51221e14592b2d9e3 to your computer and use it in GitHub Desktop.
Fibonacci implementation in python as Genarator
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 fib(): | |
a = 0 | |
b = 0 | |
while True: | |
if b == 0: | |
yield 1 | |
b = 1 | |
continue | |
a, b = b, a + b | |
yield b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment