Skip to content

Instantly share code, notes, and snippets.

@laurenachoo
Forked from kvirani/fizzbuzz_messy.rb
Last active August 29, 2015 14:20
Show Gist options
  • Save laurenachoo/2c11e31a9aa2657931e5 to your computer and use it in GitHub Desktop.
Save laurenachoo/2c11e31a9aa2657931e5 to your computer and use it in GitHub Desktop.
def range(a, b)
a.upto(b) { |x| puts fizzbuzz(x)}
end
def fizzbuzz(num)
if divby3(num) && divby5(num)
"FizzBuzz"
elsif divby5(num)
"Buzz"
elsif divby3(num)
"Fizz"
else
num
end
end
def divby5(num)
num % 5 == 0
end
def divby3(num)
num % 3 == 0
end
apple = 60
banana = 80
range(apple,banana)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment