Skip to content

Instantly share code, notes, and snippets.

@rohit-jamuar
Last active August 29, 2015 14:03
Show Gist options
  • Save rohit-jamuar/ed69663123665aed272f to your computer and use it in GitHub Desktop.
Save rohit-jamuar/ed69663123665aed272f to your computer and use it in GitHub Desktop.
Fibonacci sequence generator
def fibo_num_generator():
'''
Create an instance of 'fibo_num_generator' to use it as a generator -
e.g. g = fibo_num_generator()
In order to get the next element in the sequence --> g.next()
'''
yield 0
yield 1
yield 1
a, b = 1, 1
while True:
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