Created
March 29, 2016 23:19
-
-
Save FioFiyo/156b8da8e41a86e0266a521e0f3d4f3c to your computer and use it in GitHub Desktop.
Refactoring original FizzBuzz by making my own numbers as opposed to 1-100
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
def fizzbuzz1 | |
# | |
puts "Please put your range:" | |
#number1 = gets.chomp.to_i | |
first_num = gets.chomp.to_i | |
last_num = gets.chomp.to_i | |
n = (first_num..last_num) | |
array = n.sort | |
array.each do |fixnum| | |
if (fixnum % 3 == 0 && fixnum % 5 == 0) | |
puts "FizzBuzz #{fixnum}" | |
elsif (fixnum % 3 == 0 && fixnum != 15) | |
puts "Fizz #{fixnum}" | |
elsif (fixnum % 5 == 0 && fixnum != 15) | |
puts "Buzz #{fixnum}" | |
else puts fixnum | |
end | |
end | |
end | |
fizzbuzz1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment