Skip to content

Instantly share code, notes, and snippets.

@kangkyu
Created August 26, 2015 23:56
Show Gist options
  • Save kangkyu/f8b4d867f48348e658da to your computer and use it in GitHub Desktop.
Save kangkyu/f8b4d867f48348e658da to your computer and use it in GitHub Desktop.
def fizz_buzz(limit)
1.upto(limit).reduce("") do |string, n|
string << (n % 3 == 0 && n % 5 == 0 ? "FizzBuzz" : n % 3 == 0 ? "Fizz" : n % 5 == 0 ? "Buzz" : n.to_s)
string << "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment