Skip to content

Instantly share code, notes, and snippets.

@scottdomes
Created September 28, 2017 03:59
Show Gist options
  • Save scottdomes/46896f6d2b5b10e52d2ee8c9c42b7b8d to your computer and use it in GitHub Desktop.
Save scottdomes/46896f6d2b5b10e52d2ee8c9c42b7b8d to your computer and use it in GitHub Desktop.
# Our code should do the following things:
# Make a list of numbers from 1 to 100, inclusive
# For each number, perform the following tests on it:
# FIZZ
# If the number is divisible by 3, output 'Fizz'
# BUZZ
# If the number is divisible by 5, output 'Buzz'
# FIZZBUZZ
# If the number is divisible by BOTH 3 and 5, output 'FizzBuzz'
numbers = 1..100
numbers.each do |that_particular_number|
if that_particular_number % 3 == 0 && that_particular_number % 5 == 0
puts 'FIZZBUZZ'
elsif that_particular_number % 3 == 0
puts 'FIZZ'
elsif that_particular_number % 5 == 0
puts 'BUZZ'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment