Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

edit: In order to avoid overwriting output, the solution should read... if !multiple_of_3(i) && !multiple_of_5(i) output << i

No. Though output << i.to_s will produce the same result, his code is correct. And yours isn't if you do output << i

1. If not a multiple of 3 or 5 or 15, output = i.

2. If a multiple of 3, output << fizz.

3. If a multiple of 5, output << buzz

4. If a multiple of 15, "fizzbuzz". Already covered in 2 and 3 owing to <<

Apparently people mess up fizzbuzz even when they know it:)



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: