3 ms·
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
by irahul 14y ago
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:)