Created
September 29, 2015 20:48
-
-
Save RobertCam/0c84826f930ee305054b to your computer and use it in GitHub Desktop.
FizzBuzz refactored code
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 fizzbuzz(start, finish) | |
start = start.to_i | |
finish = finish.to_i | |
range = (start..finish) | |
for num in range | |
puts "FIZZBUZZ #{num}" if (num % 3==0)&&(num % 5==0) | |
puts "FIZZ #{num}" if num % 3==0 | |
puts "BUZZ #{num} " if num % 5==0 | |
puts num if (num % 3!=0)&&(num % 5!=0) | |
end | |
end | |
fizzbuzz("1","10") | |
fizzbuzz(50, 200) | |
fizzbuzz(-20, 20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment