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

Hm. I don't quite see how to do it, but I think I know one of the tricks you have in mind. If you have the book Hacker's Delight handy, open it up to 10-17, "Test for Zero Remainder after Division by a Constant". With n<=100 you can get an intermediate result with a single 32-bit multiply and mask that will allow testing divisibility by 3 and 5 each with a single operation (and a bit of union trickery to access high bits without counting as an operation). I just don't see how to make the test 'not a multiple of 3 or 5' come out of that in one C operation yet. So maybe this isn't the right technique.


and having allowed myself to read the rest of the replies .. fizz bzzzzt!




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

Search: