Skip to content

Instantly share code, notes, and snippets.

@att288
Last active May 5, 2019 20:36
Show Gist options
  • Save att288/a01ce011ce0d95df3e1c6f9c9701d051 to your computer and use it in GitHub Desktop.
Save att288/a01ce011ce0d95df3e1c6f9c9701d051 to your computer and use it in GitHub Desktop.
fibonacci_sequence_generator.py
def fibonacci_sequence(n):
curr_val = 0
next_val = 1
for i in range(n):
yield curr_val
curr_val, next_val = next_val, curr_val + next_val
if __name__ == '__main__':
fib_seq = []
for fn in fibonacci_sequence(10):
fib_seq.append(fn)
print(fib_seq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment