Last active
January 2, 2016 05:09
-
-
Save jackhooper/8254699 to your computer and use it in GitHub Desktop.
A very clean implementation of FizzBuzz in Ruby.
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
# 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