Created
October 17, 2012 04:05
-
-
Save michaeltwofish/3903646 to your computer and use it in GitHub Desktop.
fizzbuzz
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
def fizzbuzz(number) | |
case | |
when number % 3 == 0 && number % 5 == 0 | |
"Fizz, Buzz" | |
when number % 3 == 0 | |
"Fizz" | |
when number % 5 == 0 | |
"Buzz" | |
else | |
number.to_s | |
end | |
end | |
(1..100).each do |number| | |
puts fizzbuzz(number) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment