-
-
Save shinobcrc/efc820d9ab130299c93893392e49bae1 to your computer and use it in GitHub Desktop.
W1D2 Homework Exercise - Ruby - Messy Fizzbuzz
This file contains 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 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