Created
November 2, 2016 21:53
-
-
Save sergiomaia/84dcd5e2a44ca81200e7a920caa3e88c to your computer and use it in GitHub Desktop.
This file contains 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.upto(100) do |i| | |
if i % 3 == 0 && i % 5 == 0 | |
puts "FizzBuzz" | |
elsif i % 3 == 0 | |
puts "Fizz" | |
elsif i % 5 == 0 | |
puts "Buzz" | |
else | |
puts i | |
end | |
end | |
######################################################################### | |
1.upto(100) do |i| | |
str = "" | |
str += "Fizz" if i % 3 == 0 | |
str += "Buzz" if i % 5 == 0 | |
str += i if str.blank? | |
puts str | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment