Skip to content

Instantly share code, notes, and snippets.

@sergiomaia
Created November 2, 2016 21:53
Show Gist options
  • Save sergiomaia/84dcd5e2a44ca81200e7a920caa3e88c to your computer and use it in GitHub Desktop.
Save sergiomaia/84dcd5e2a44ca81200e7a920caa3e88c to your computer and use it in GitHub Desktop.
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