Skip to content

Instantly share code, notes, and snippets.

@henry0312
Created August 22, 2011 16:00
Show Gist options
  • Save henry0312/1162754 to your computer and use it in GitHub Desktop.
Save henry0312/1162754 to your computer and use it in GitHub Desktop.
FizzBuzz Question
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