Hacker News new | ask | show | jobs
by stephengillie 3168 days ago
My 15 falls through both the 3 and the 5 paths. So I must do 3 first, or 15 will be BuzzFizz.
2 comments

No, I'm saying just do a switch with four branches, %15, %5, %3, default, and break all of them. That way you're explicit about the ambiguous case and you avoid string concat or stateful stdout logic.
I think the point was that you do

If n%15==0

First, then the others. But it’s a pedantic point anyway (like this one)

Or you can print fizz and buzz in independent statements, or it against printing the raw number, and then print a new line for each number in the end.