Last active
March 25, 2020 09:24
-
-
Save diegoquintanav/dd2994f56bcb077bfa7410cd2cf9a23d to your computer and use it in GitHub Desktop.
fizzbuzz
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
import sys [0/6141] | |
"""A simple python implementation of the FizzBuzz problem. | |
*caveat*: It considers zero as divisible by three and five | |
see https://www.google.com/search?client=ubuntu&channel=fs&q=fizzbuzz+problem&ie=utf-8&oe=utf-8 | |
and http://wiki.c2.com/?FizzBuzzInManyProgrammingLanguages | |
""" | |
def fizzbuzz(number): | |
for n in range(number): | |
what = '' | |
if n % 3 == 0: | |
what = what + "Fizz" | |
if n % 5 == 0: | |
what = what + "Buzz" | |
print(n, what) | |
if __name__=='__main__': | |
try: | |
fizzbuzz(int(sys.argv[1])) | |
except (IndexError, ValueError): | |
print("help: python fizzbuzz.py <integer>") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment