Skip to content

Instantly share code, notes, and snippets.

@luxerama
Created August 14, 2013 13:03
Show Gist options
  • Save luxerama/6230840 to your computer and use it in GitHub Desktop.
Save luxerama/6230840 to your computer and use it in GitHub Desktop.
Fizz Buzz
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