Skip to content

Instantly share code, notes, and snippets.

@earlonrails
Created October 21, 2011 01:37
Show Gist options
  • Save earlonrails/1302897 to your computer and use it in GitHub Desktop.
Save earlonrails/1302897 to your computer and use it in GitHub Desktop.
FIZZ BUZZ! This is to make sure that no one (myself mainly) has to figure out the fizz buzz problem anymore!
(1..100).each do |x|
case
when 0 == ((x%3)+(x%5))
puts "fizz buzz"
when 0 == (x%3)
puts "fizz"
when 0 == (x%5)
puts "buzz"
else
puts x
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment