Last active
August 29, 2015 14:25
-
-
Save HarryCoops/4f58340f66657dfc7f45 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# generator function for the fibonacci sequence | |
def fibonacci(): | |
a, b = 0, 1 | |
while True: | |
yield a | |
a, b = b, a + b | |
def main(): | |
term = int(input('nth term:')) | |
for index, i in enumerate(fibonacci()): | |
if index <= term: | |
print(i) | |
else: | |
break | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment