Created
December 7, 2015 20:19
-
-
Save jb41/1096fb3542a286a75fad 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 fizzbuzz(number) | |
return "FizzBuzz" if is_divisible_by_fifteen?(number) | |
return "Buzz" if is_divisible_by_five?(number) | |
return "Fizz" if is_divisible_by_three?(number) | |
number | |
end | |
def is_divisible_by_three?(number) | |
is_divisible_by(number, 3) | |
end | |
def is_divisible_by_five?(number) | |
is_divisible_by(number, 5) | |
end | |
def is_divisible_by_fifteen?(number) | |
is_divisible_by(number, 15) | |
end | |
def is_divisible_by(number, divisor) | |
number % divisor == 0 | |
end | |
(1..100).each do |number| | |
puts fizzbuzz(number) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment