Skip to content

Instantly share code, notes, and snippets.

@jshawl
Created July 29, 2016 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jshawl/3a83e13e01c55f4f835c85f60243655b to your computer and use it in GitHub Desktop.
Save jshawl/3a83e13e01c55f4f835c85f60243655b to your computer and use it in GitHub Desktop.
# regular
for i in range(1,101):
if i % 15 == 0:
print "fizzbuzz"
elif i % 3 == 0:
print "fizz"
elif i % 5 == 0:
print "buzz"
else:
print i
"""
"""
# Bonus 1
for i in range(1,101):
str = ''
if i % 3 == 0:
str += "fizz"
if i % 5 == 0:
str += "buzz"
if i % 3 != 0 and i % 5 != 0:
str = i
print str
"""
"""
# Bonus 2
def fizzbuzz(n,i=1):
if(i==n+1):
return
if i % 15 == 0:
print "fizzbuzz"
elif i % 3 == 0:
print "fizz"
elif i % 5 == 0:
print "buzz"
else:
print i
fizzbuzz(n,i+1)
fizzbuzz(100)
"""
"""
# Bonus 3
class FizzBuzz():
def __init__(self, n, i=1):
self.loop(n,i+1)
def loop(self,n,i=1):
if(i==n+1):
return
if i % 15 == 0:
print "fizzbuzz"
elif i % 3 == 0:
print "fizz"
elif i % 5 == 0:
print "buzz"
else:
print i
self.loop(n, i+1)
FizzBuzz(100)
"""
multi
line
commentes
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment