Last active
April 27, 2016 02:01
-
-
Save charmainetham/49937e00f6556f6e7da45acacc1c87ff to your computer and use it in GitHub Desktop.
FIZZBUZZ
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
#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