1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Binary divisibility by 3

  1. Nov 5, 2009 #1
    Well i found this sentence: "If the number of even bits minus the number of odd bits is a multiple of 3 (e.g. -3,0,3,6, etc) then the number is divisible by three." Can anyone tell me the proof of this?
    Thanks
     
  2. jcsd
  3. Nov 5, 2009 #2
    These rules can be found from modular arithmetic.
    http://en.wikipedia.org/wiki/Modular_arithmetic

    For binary number in particular we can write the following equation for a binary number where all equations are taking mod 3
    [tex]
    (a_n\dotsb a_3a_2a_1a_0)_b=2^n a_n+\dotsb+ 2^3 \cdot a_3+2^2\cdot a_2+2\cdot a_1+a_0=(-1)^n a_n+\dotsb+ (-1) \cdot a_3+(+1)\cdot a_2+(-1)\cdot a_1+a_0
    [/tex]
    Here you say that one has the alternatively add the bits and the final result will have the same divisibility by 3 as the complete binary number.

    Have a look at Wikipedia and then ask, if something is unclear. I admit Wikipedia doesn't explain this well. Maybe you can also find a better reference.
     
  4. Nov 5, 2009 #3
    Hmm, couldn't find a very concise summary of modular arithmetic. Basically what you need to know is that one can write equations where one only cares if the remainder to some division is the same. For example
    [tex]
    9=19=29=\dotsb\qquad\text{mod 10}
    [/tex]
    since all numbers have the same remainder w.r.t. division by 10. Note that also
    [tex]
    9=-1=-11=\dotsb\qquad\text{mod 10}
    [/tex]
    since in general you can add or subtract any multiple of 10 (in this case).

    Now some rule are, that for you can replace any integer by another which gives the same remainder. For example
    [tex]
    156=12\cdot 13=2\cdot 3=6\qquad\text{mod 10}
    [/tex]
    as you can check for yourself.

    You can do this in equations also at any instant of the calculation
    [tex]
    1116=12\cdot (89+4)=2\cdot (9+4)=2\cdot 13=2\cdot 3=6\qquad\text{mod 10}
    [/tex]
    where in some steps I replaced number by their remainder w.r.t. division by 10 (which is basically the last digit of the number)

    That what I did for your problem
    [tex]
    2^n=(-1)^n\qquad\text{mod 3}
    [/tex]
    where I replaced 2 with the "equivalent" remainder-wise -1.
     
  5. Nov 5, 2009 #4
    Well thanks for the help! First time in my life i hear about modular arithmetic! It took me some time to understand but thanks to your answer i think i got it!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Binary divisibility by 3
  1. Binary Arithmetic (Replies: 3)

  2. Division by 3 (Replies: 16)

Loading...