Created
October 30, 2021 08:08
-
-
Save crazo7924/8e23ad110366796a08d8bb8e0553de76 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
| #!/usr/bin/python3 | |
| import sys | |
| def print_fibonacci(howMany): | |
| a, b = 0, 1 | |
| while a < howMany: | |
| print(a) | |
| a, b = b, a + b | |
| def main(): | |
| limit = 0 | |
| if (len(sys.argv) != 2): | |
| limit = 10 | |
| else: | |
| try: | |
| limit = int(sys.argv[1]) | |
| print_fibonacci(int(limit)) | |
| except ValueError as err: | |
| print('An integer is required: {0}'.format(err)) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment