Created
July 29, 2016 14:01
-
-
Save jshawl/3a83e13e01c55f4f835c85f60243655b to your computer and use it in GitHub Desktop.
This file contains 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
# 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