Skip to content

Instantly share code, notes, and snippets.

@jshawl jshawl/fb.py
Created Jul 29, 2016

Embed
What would you like to do?
# 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
You can’t perform that action at this time.