Hacker News new | ask | show | jobs
by tayo42 389 days ago
the article has a special string that says "fizz buzz",

they saying its unnecessary because if you go in order you first print "fizz", then print "buzz" which will always print "fizz buzz" for the equivalent of " mod 15" you don't need a special string that like.

the "if (m3 || m5)" is just printing a newline because under that condition you printed something earlier.

1 comments

It’s still an extra condition. So it really doesn’t matter if you’re printing “Fizz Buzz” string or not, it’s the same amount of branching.
add another bool that stores the information to write a newline whenever either fizz or buzz happen and you don't need the third branch