Created
August 14, 2013 13:03
-
-
Save luxerama/6230840 to your computer and use it in GitHub Desktop.
Fizz Buzz
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
class Fixnum | |
def fizz_buzz? | |
self.fizz? and self.buzz? | |
end | |
def fizz? | |
self % 3 == 0 | |
end | |
def buzz? | |
self % 5 == 0 | |
end | |
end | |
i = 100 | |
while i > 0 | |
case | |
when i.fizz_buzz? | |
puts "FizzBuzz" | |
when i.fizz? | |
puts "Fizz" | |
when i.buzz? | |
puts "Buzz" | |
else | |
puts i | |
end | |
i -= 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment