Skip to content

Instantly share code, notes, and snippets.

@michaeltwofish
Created October 17, 2012 04:05
Show Gist options
  • Save michaeltwofish/3903646 to your computer and use it in GitHub Desktop.
Save michaeltwofish/3903646 to your computer and use it in GitHub Desktop.
fizzbuzz
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