Created
September 1, 2015 21:17
-
-
Save heavymetta/f2b92635fbe1315fe33f to your computer and use it in GitHub Desktop.
FizzBuzz Refactor
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_value(i) | |
if i % 5 == 0 && i % 3 == 0 | |
"FizzBuzz" | |
elsif i % 5 == 0 | |
"Buzz" | |
elsif i % 3 == 0 | |
"Fizz" | |
else | |
i | |
end | |
end | |
def fizzbuzz (start, endval) | |
start.upto(endval) do |i| | |
puts fizzbuzz_value(i) | |
end | |
end | |
fizzbuzz(5, 55) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment