Last active
May 5, 2019 20:36
-
-
Save att288/a01ce011ce0d95df3e1c6f9c9701d051 to your computer and use it in GitHub Desktop.
fibonacci_sequence_generator.py
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 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