Last active
June 1, 2019 08:31
-
-
Save shuuuuun/af93401324d65a85bdb15a7625ef2124 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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