Skip to content

Instantly share code, notes, and snippets.

@shinobcrc
Forked from kvirani/fizzbuzz_messy.rb
Last active June 22, 2016 03:35
Show Gist options
  • Save shinobcrc/efc820d9ab130299c93893392e49bae1 to your computer and use it in GitHub Desktop.
Save shinobcrc/efc820d9ab130299c93893392e49bae1 to your computer and use it in GitHub Desktop.
W1D2 Homework Exercise - Ruby - Messy Fizzbuzz
def fizzbuzz(s, f)
s.upto(f) { |x| puts e(x) }
end
def e(number)
if div_3?(number) && div_5?(number)
"FizzBuzz"
elsif div_5?(number)
"Buzz"
elsif div_3?(number)
"Fizz"
else
number
end
end
def div_5?(x)
x % 5 == 0
end
def div_3?(x1)
x1 % 3 == 0
end
a = 60
b = 80
fizzbuzz(a,b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment