Skip to content

Instantly share code, notes, and snippets.

@FioFiyo
Created March 29, 2016 23:19
Show Gist options
  • Save FioFiyo/156b8da8e41a86e0266a521e0f3d4f3c to your computer and use it in GitHub Desktop.
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
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