Created
August 22, 2011 16:00
-
-
Save henry0312/1162754 to your computer and use it in GitHub Desktop.
FizzBuzz Question
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
def fizz_buzz(n) | |
1.upto(n) do |i| | |
if i % 15 == 0 then | |
print "FizzBuzz\n" | |
elsif i % 3 == 0 then | |
print "Fizz\n" | |
elsif i % 5 == 0 then | |
print "Buzz\n" | |
else | |
print i, "\n" | |
end | |
end | |
end | |
fizz_buzz(50) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment