Skip to content

Instantly share code, notes, and snippets.

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

tk0221 commented Nov 21, 2016

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