Created
September 26, 2013 08:10
-
-
Save zh4ngx/6711242 to your computer and use it in GitHub Desktop.
Extensible FizzBuzz
This file contains hidden or 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
def fizzbuzz(max): | |
1.upto(max).each do |num| | |
line = '' | |
line << 'Fizz' if num % 3 == 0 | |
line << 'Buzz' if num % 5 == 0 | |
line = num if line.empty? | |
p line | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment