Skip to content

Instantly share code, notes, and snippets.

@jb41
Created December 7, 2015 20:19
Show Gist options
  • Save jb41/1096fb3542a286a75fad to your computer and use it in GitHub Desktop.
Save jb41/1096fb3542a286a75fad to your computer and use it in GitHub Desktop.
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