Skip to content

Instantly share code, notes, and snippets.

@raySavignone
Forked from kvirani/fizzbuzz_messy.rb
Last active August 29, 2015 14:14
Show Gist options
  • Save raySavignone/c2373411cd591faaf3c0 to your computer and use it in GitHub Desktop.
Save raySavignone/c2373411cd591faaf3c0 to your computer and use it in GitHub Desktop.
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)
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