Binary divisibility by 3

Possible duplicate:
Check if the number is divisible by 3

Is it true that a binary number is divisible by 3 if it has an even number of units? for example, 11000 is divided by 3, while 1110 is not.

+7
algorithm
source share
2 answers

No - there is a trick, but it is a little more complicated than this - you need to count the number 1 in even positions and the number 1 in odd positions. See Check if the number is divisible by 3 .

+10
source share

No, this is wrong. For example, 5_dec = 101_bin is not divisible by 3. To check for divisbility by three, you must count the number of units in an even position and subtract the number of units in odd positions. If the difference is divided by three, the original number is divided by three (which, in turn, can be verified by repeating the same rule).

+5
source share

All Articles