Skip to content

Instantly share code, notes, and snippets.

@jackhooper
Last active January 2, 2016 05:09
Show Gist options
  • Save jackhooper/8254699 to your computer and use it in GitHub Desktop.
Save jackhooper/8254699 to your computer and use it in GitHub Desktop.
A very clean implementation of FizzBuzz in Ruby.
# Jack Hooper 2014
def fizzbuzz(n)
return "FizzBuzz" if n.modulo(15).zero?
return "Fizz" if n.modulo(3).zero?
return "Buzz" if n.modulo(5).zero?
n
end
1.upto(100) { |i| puts fizzbuzz(i) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment