shuuuuun
6/1/2019 - 8:24 AM

fizzbuzz.rb

100.times do |i|
  str = ''
  str += 'Fizz' if i % 3 == 0
  str += 'Buzz' if i % 5 == 0
  str += i.to_s if str == ''
  puts str
end

100.times do |i|
  print 'Fizz' if i % 3 == 0
  print 'Buzz' if i % 5 == 0
  print i.to_s if i % 3 != 0 && i % 5 != 0
  puts
end

100.times do |i|
  if i % 15 == 0
    puts 'FizzBuzz'
  elsif i % 3 == 0
    puts 'Fizz'
  elsif i % 5 == 0
    puts 'Buzz'
  else
    puts i.to_s
  end
end

100.times do |i|
  case
  when i % 15 == 0
    puts 'FizzBuzz'
  when i % 3 == 0
    puts 'Fizz'
  when i % 5 == 0
    puts 'Buzz'
  else
    puts i.to_s
  end
end