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!

Reversing Numbers

  1. Aug 26, 2009 #1
    Okay, this one is probably going to get laughed out of town, but it's annoying me so I shall ask it anyway.

    1. Take any number of 2 digits or greater, reverse it (i.e. 12 becomes 21 or 4765 becomes 5674).
    2. Take the 'reversed' number away from the original number.
    3. Why is the answer to this simple sum ALWAYS either 0* or divisible by 3?

    Try it with any random numbers
    12-21 = -9
    4765-5674 = -909
    863789532 - 235987368 = 627802164

    All of these answers are divisible by 3. WHY?

    * I had to put in the bit about it could be 0 for those who will point out that 121 or anything similar when reversed is still 121 and hence taken away from itself results in 0.
  2. jcsd
  3. Aug 26, 2009 #2


    User Avatar
    Science Advisor
    Homework Helper

    I think it is easy to prove this by induction.

    Let n be a natural number and let L be its length (number of digits). Denote by n' its "reversed" number.
    Suppose that for n it is true that n - n' = 0 (mod 3).
    Now add 1 to n. Then if we take the reverse of n + 1, we have to add 10L to n'. So:
    (n + 1) - (n + 1)' = (n + 1) - (n' + 10L) = (n - n') + (1 - 10L) = 0 + 10L - 1 (mod 3).
    For the last expression is easy to see that it is always 0 mod 3 (in fact I think it will be divisible by 9, because it consists of only 9's).

    Check the base case => done
    (For the base case you might want to take 12 or something, because for all numbers < 12 it is completely trivial, although in principle checking it for n = 1 is sufficient).
    Last edited: Aug 26, 2009
  4. Aug 26, 2009 #3


    User Avatar
    Science Advisor

    It also follows immediately from the property of base 10 natural numbers, that they are congruent with their digit sum modulo 9.
  5. Aug 26, 2009 #4


    User Avatar
    Science Advisor
    Homework Helper

    The digit sum of a base-b number is congruent to the number mod b-1, so in base 10 the number and its reverse are congruent mod 9 (since they're mutually congruent mod 9 to their shared digit sum). Thus the number minus its reverse is divisible by 9.
  6. Sep 1, 2009 #5
    While the answers given here, proofs of the assertion, will be most pleasing to the professional mathematician who always seeks to provide answers in the form of a proof, I think the original asker, in asking "WHY?", was likely looking for something a little less formal and a little more intuitive, so that is what I'll attempt to provide here.

    Let's look at the number 1234. When we reverse it, what happens?
    We go from 1234 to 4321. The "4" moves from the 1's place to the 1000's place. Before the move it represented 4 * 1, or 4 * 10^0. Now it represents 4 * 10^3. We gained the latter and lost the former; so the "movement" of the digit "4" produces a change in value of +4000-4 = +4*10^3-4*10^0 = 4*(10^3-10^0).

    Examination of the movement of the other digits shows that each digit's movement brings about a change in value of the form


    where n and m are non-negative integers. If you factor out the smaller term, you end up with something of the form

    +/- digit*(10^p - 1)*10^q where p is a positive integer and q a nonnegative integer. The portion (10^p - 1) can be shown by simple algebra to be a multiple of (10 - 1) or 9.

    So, every movement of a digit in the number brings about a change in the value of the overall number that is a multiple of 9; therefore the sum of all digit-movements is also a multiple of 9.

    Note that this doesn't apply to just reversals; any scrambling of the digits of a number produces a similar multiple-of-9 change in the number's value. For example, 1234 and 2341 differ by a multiple of 9.

    It gets even more interesting if we consider "leading zeros". For example, 23010 can be considered a rearrangement of the digits in the number 123, because we might write 123 as 00123. (These leading zeros "add" 0 thousands and 0 ten thousands to the value of 123, thus not changing the value at all.) Differences between numbers paired in this way will be multiples of 9.

    And as the others mentioned, the thing that makes "9" so special is that we use a base 10 number system. If we used base 16, for example, we'd find all digit-reversal pairs to differ by a multiple of (16-1), or 15.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook