Skip to content

Instantly share code, notes, and snippets.

@diegoquintanav
Last active March 25, 2020 09:24
Show Gist options
  • Save diegoquintanav/dd2994f56bcb077bfa7410cd2cf9a23d to your computer and use it in GitHub Desktop.
Save diegoquintanav/dd2994f56bcb077bfa7410cd2cf9a23d to your computer and use it in GitHub Desktop.
fizzbuzz
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