Skip to content

Instantly share code, notes, and snippets.

@kvirani
Created March 5, 2014 02:28
Show Gist options
  • Save kvirani/d0c7f3c215efe78cfa2e to your computer and use it in GitHub Desktop.
Save kvirani/d0c7f3c215efe78cfa2e 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