-
-
Save raySavignone/c2373411cd591faaf3c0 to your computer and use it in GitHub Desktop.
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 method_fb(s, f) | |
s.upto(f) { |x| | |
puts e(x) | |
} | |
end | |
def method_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 | |
method_fb(a, b) |
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(starting_number,ending_number) | |
if starting_number > ending_number | |
puts "Please input correct numbers" | |
end | |
starting_number.upto(ending_number) do |i| | |
puts "FizzBuzz" if i % 5 == 0 && i % 3 == 0 | |
puts "Buzz" if i % 5 == 0 | |
puts "Fizz" if i % 3 == 0 | |
puts i if i % 5 !=0 && i % 3 != 0 | |
end | |
end | |
fizzbuzz(1,100) | |
fizzbuzz(3,1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment