Skip to content

Instantly share code, notes, and snippets.

@tomohiro
Last active December 16, 2015 09:09
Show Gist options
  • Save tomohiro/5410581 to your computer and use it in GitHub Desktop.
Save tomohiro/5410581 to your computer and use it in GitHub Desktop.
count = 1
while count <= 100
if count % 3 == 0 && count % 5 == 0
puts 'FizzBuzz'
elsif count % 3 == 0
puts 'Fizz'
elsif count % 5 == 0
puts 'Buzz'
else
puts count
end
count += 1
end
(1..100).each do |i|
puts case
when i % 15 == 0 then 'FizzBuzz'
when i % 3 == 0 then 'Fizz'
when i % 5 == 0 then 'Buzz'
else i
end
end
(1..100).each { |i| puts i % 15 == 0 ? :FizzBuzz : i % 3 == 0 ? :Fizz : i % 5 == 0 ? :Buzz : i }
puts (1..100).map { |i| i % 15 == 0 ? :FizzBuzz : i % 3 == 0 ? :Fizz : i % 5 == 0 ? :Buzz : i }.join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment