Created
September 4, 2014 01:33
-
-
Save noqcks/3e9e50b80186796dec45 to your computer and use it in GitHub Desktop.
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 fizz_buzz(num_start,num_stop) | |
num_start.upto(num_stop) { |num| | |
puts evaluate(num) | |
} | |
end | |
def evaluate(num) | |
if div_3?(num) && div_5?(num) | |
"FizzBuzz" | |
elsif div_5?(num) | |
"Buzz" | |
elsif div_3?(num) | |
"Fizz" | |
else | |
num | |
end | |
end | |
def div_5?(num) | |
num % 5 == 0 | |
end | |
def div_3?(num) | |
num % 3 == 0 | |
end | |
num_start = 60 | |
num_stop = 80 | |
fizz_buzz(num_start, num_stop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment