On 25/05/2016 04:05, Zak Seidov via math-fun wrote:
To be fair: parity rule is the same in b10 & b2 while div-by-4 rule is even simper in b2. However, in div5 case, b2 again desperately looses:(
Well, sure, divisibility by p is easier to test in a base that's a multiple of p. But divisibility by 5 isn't *hard* in binary. Group digits in pairs and add and subtract alternately. So e.g. 45893 -> 1011001101000101 -> -10+11-00+11-01+00-01+01 -> -10+11+11-01 [deleting 00 and cancelling pairs] -> 11 [noticing that 11-10-01=0] and we correctly infer that 45893 is 3 mod 5. (You can work from the left instead of from the right so long as you remember to add an extra 0 if need be and either care only whether the result is 0 or make the appropriate corrections for zero-padding and sign-changing to get the result mod 5.) -- g