Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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...


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.


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: