Skip to content

Instantly share code, notes, and snippets.

@shuuuuun
Last active June 1, 2019 08:31
Show Gist options
  • Save shuuuuun/af93401324d65a85bdb15a7625ef2124 to your computer and use it in GitHub Desktop.
Save shuuuuun/af93401324d65a85bdb15a7625ef2124 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment