3 ms·
They have n `mod` 3 == 0 && n `mod` 5 == 0 And you have if (m3 || m5) I really don't see what point you're trying to make here...
by unsnap_biceps 1y ago
They have
n `mod` 3 == 0 && n `mod` 5 == 0
And you have
if (m3 || m5)
I really don't see what point you're trying to make here...
- tayo42 1y agothe 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.
- hnlmorg 1y agoIt’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.
- airstrike 1y agoadd another bool that stores the information to write a newline whenever either fizz or buzz happen and you don't need the third branch