/fizzbuzz_messy.rb Secret
Created
March 5, 2014 02:28
-
Star
(0)
You must be signed in to star a gist -
Fork
(239)
You must be signed in to fork a gist
-
-
Save kvirani/d0c7f3c215efe78cfa2e to your computer and use it in GitHub Desktop.
W1D2 Homework Exercise - Ruby - Messy Fizzbuzz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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