Skip to content

Instantly share code, notes, and snippets.

@cristinelpopescu
Created April 13, 2021 11:09
Show Gist options
  • Save cristinelpopescu/496ea18939cabdf5155534ed001bb106 to your computer and use it in GitHub Desktop.
Save cristinelpopescu/496ea18939cabdf5155534ed001bb106 to your computer and use it in GitHub Desktop.
# fibonacci - generator
def fib(number):
a = 0
b = 1
for i in range(number):
yield a
temp = a
a = b
b = temp + b
for x in fib(20):
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment