Skip to content

Instantly share code, notes, and snippets.

@tk0221
Created November 21, 2016 05:50
Show Gist options
  • Save tk0221/c0f613a7a40aa78946f11c9667077618 to your computer and use it in GitHub Desktop.
Save tk0221/c0f613a7a40aa78946f11c9667077618 to your computer and use it in GitHub Desktop.
# @param {Integer} n
# @return {String[]}
def fizz_buzz(n)
tmp = []
(1..n).each do |i|
tmp.push("FizzBuzz") && next if i % 15 == 0
tmp.push("Fizz") && next if i % 3 == 0
tmp.push("Buzz") && next if i % 5 == 0
tmp.push(i.to_s)
end
return tmp
end
@tk0221
Copy link
Author

tk0221 commented Nov 21, 2016

112ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment