Skip to content

Instantly share code, notes, and snippets.

@Andsbf
Created March 3, 2015 22:13
Show Gist options
  • Save Andsbf/464e9486260374f34899 to your computer and use it in GitHub Desktop.
Save Andsbf/464e9486260374f34899 to your computer and use it in GitHub Desktop.
FizzBuzz Refactor Exercise
def fizzBuzz(_start,_end)
_start.upto(_end) {|i|
puts "Fizz" if i%3 == 0 && i%5 != 0
puts "Buzz" if i%3 != 0 && i%5 == 0
puts "FizzBuzz" if i%3 == 0 && i%5 == 0
puts i if i%3 != 0 && i%5 != 0
}
end
fizzBuzz(3,30)
fizzBuzz(30,45)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment