Skip to content

Instantly share code, notes, and snippets.

@charmainetham
Last active April 27, 2016 02:01
Show Gist options
  • Save charmainetham/49937e00f6556f6e7da45acacc1c87ff to your computer and use it in GitHub Desktop.
Save charmainetham/49937e00f6556f6e7da45acacc1c87ff to your computer and use it in GitHub Desktop.
FIZZBUZZ
#first prompting user
puts "what number would you like to start with"
start = gets.chomp
puts "what number would you like to end with?"
endd = gets.chomp
# Define the variables
(start.to_i..endd.to_i).each do |i|
divby5 = (i % 5 == 0)
divby3 = (i % 3 == 0)
#creating cases
case
when divby5 && divby3
puts "Fizzbuzz"
when divby3
puts "Fizz"
when divby5
puts "Buzz"
else
puts i
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment