Last active
December 16, 2015 09:09
-
-
Save tomohiro/5410581 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
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 |
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
(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 |
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
(1..100).each { |i| puts i % 15 == 0 ? :FizzBuzz : i % 3 == 0 ? :Fizz : i % 5 == 0 ? :Buzz : i } |
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
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