Skip to content

Instantly share code, notes, and snippets.

@jonatas
Created July 9, 2012 02:38
Show Gist options
  • Save jonatas/3073900 to your computer and use it in GitHub Desktop.
Save jonatas/3073900 to your computer and use it in GitHub Desktop.
fizz buzz
(1..100).to_a.each do |i|
multiple_three = i % 3 == 0
multiple_five = i % 5 == 0
puts "#{i} #{[ ('Fizz' if multiple_three),
('Buzz' if multiple_five)
].compact.join("-")}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment