Module: JobInterview::FizzBuzz
- Included in:
- Answer
- Defined in:
- lib/job_interview/fizz_buzz.rb
Instance Method Summary collapse
Instance Method Details
#fizz_buzz(max) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/job_interview/fizz_buzz.rb', line 4 def fizz_buzz(max) Array.new(max) do |i| j = i + 1 val = (j % 3 == 0 ? "Fizz" : "") + (j % 5 == 0 ? "Buzz" : "") val.empty? ? j.to_s : val end end |