Skip to content

Instantly share code, notes, and snippets.

@MaggieMoss
Created July 4, 2016 23:23
Show Gist options
  • Save MaggieMoss/05e5b380c9727934802ca591581c81ef to your computer and use it in GitHub Desktop.
Save MaggieMoss/05e5b380c9727934802ca591581c81ef to your computer and use it in GitHub Desktop.
# tonight we went over how to solve fizzbuzz
# see if you can try to improve our solution.
numbers = (1..100) # [1, 2, 3, 4, 5, 6 .. 100]
numbers.each do |number|
if number % 5 == 0 && number % 3 == 0
puts "FizzBuzz"
elsif number % 5 == 0
puts "Buzz"
elsif number % 3 == 0
puts "Fizz"
else
puts number
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment