Skip to content

Instantly share code, notes, and snippets.

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