Skip to content

Instantly share code, notes, and snippets.

@noqcks
Created September 4, 2014 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noqcks/3e9e50b80186796dec45 to your computer and use it in GitHub Desktop.
Save noqcks/3e9e50b80186796dec45 to your computer and use it in GitHub Desktop.
def fizz_buzz(num_start,num_stop)
num_start.upto(num_stop) { |num|
puts evaluate(num)
}
end
def evaluate(num)
if div_3?(num) && div_5?(num)
"FizzBuzz"
elsif div_5?(num)
"Buzz"
elsif div_3?(num)
"Fizz"
else
num
end
end
def div_5?(num)
num % 5 == 0
end
def div_3?(num)
num % 3 == 0
end
num_start = 60
num_stop = 80
fizz_buzz(num_start, num_stop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment