Skip to content

Instantly share code, notes, and snippets.

@ruxandrafed
Forked from davidvandusen/fizzbuzz.rb
Last active September 2, 2015 01:14
Show Gist options
  • Save ruxandrafed/046528a63bdcd168d731 to your computer and use it in GitHub Desktop.
Save ruxandrafed/046528a63bdcd168d731 to your computer and use it in GitHub Desktop.
def fizzbuzz_output(number)
result = ""
result << "Fizz" if number % 3 == 0
result << "Buzz" if number % 5 == 0
result = number if result.empty?
result
end
def fizzbuzz(a,b)
a.upto(b) do |number|
puts fizzbuzz_output(number)
end
end
puts "Insert starting number:"
starting = gets.chomp.to_i
puts "Insert ending number:"
ending = gets.chomp.to_i
fizzbuzz(starting,ending)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment