Y
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
reificator
3167 days ago
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.
link
jackweirdy
3167 days ago
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)
link
sk0g
3167 days ago
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.
link