Skip to content

Instantly share code, notes, and snippets.

@bomatson
Last active August 29, 2015 14:02
Show Gist options
  • Save bomatson/f1a700f4453731ce3f9e to your computer and use it in GitHub Desktop.
Save bomatson/f1a700f4453731ce3f9e to your computer and use it in GitHub Desktop.
def check_for_fizz(n)
if (n % 15).zero?
"FizzBuzz"
elsif (n % 5).zero?
"Buzz"
elsif (n % 3).zero?
"Fizz"
else
n
end
end
# then use the function in your loop:
1.upto(100) do |n|
puts check_for_fizz(n)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment