Saturday, November 5, 2011

Numbers that divide...

Think of a four digit number say 4321 (call this number N1). You could form another four digit number by reversing the digits. This will give you the number 1234. Call this number N2. Lets us try to see if the numbers can divide each other. 4321/1234 is not an integer. This number N2 does not divide the number N1. Are there any such number pairs such that one divides the other? Assume that numbers do not start with 0. We’re also not interested in the trivial “palindrome” solutions.

Some interesting facts;

There are no two or three digit number pairs which have the property mentioned above.

For four digit numbers, there are two (9801, 1089) and (8712, 2178).

In general, number pairs of the form [11*(10^R -1)*9, 11*(10^R-1)*1] and [11*(10^R -1)*8, 11*(10^R-1)*2] have the said property. The four digit pairs mentioned above are (11*99*9, 11*99*1) and (11*99*8, 11*99*2). The five digit number pairs are (11*999*9, 11*999*1) and (11*999*8, 11*999*2) which are (98901, 10989) and (87912, 21978).The six digit number pairs are (11*9999*9, 11*9999*1) and (11*9999*8, 11*9999*2) or (989901, 109989) and (879912, 219978). You can get more of these with more digits by inserting as many 9’s as you want in the middle of those pairs.

Let us assume that the number is abcd. Its reverse is dcba. I’ll assume that abcd is the larger of the two. The ratio abcd/dcba is an integer. Let’s call that ‘R’. R is not 0 or 1.

I’ll illustrate how you can find the number for the case where ‘R’ is 4.

1000a + 100b + 10c + d = 4000d + 400c + 40b + 4a.

Rearrange that to

996a + 60b = 3999d + 390c.

Now the LHS is even; Hence RHS must be as well. This implies that d must be even since 3999 is odd. Smallest value of d is 2.

Look at the LHS again, since a and b are lesser than 10, this number can never be larger than 9504. Hence d must be lesser than 3. That implies d is 2.

Now we have
996a + 60b = 7998 + 390c.

Or a = 8 + (30 + 390c +-60b)/996.

Since a must be lesser than 9 and since all terms in the bracket are multiples of 10 which means they won’t add up to 996, a = 8 and 30 + 390c -60b = 0. Hence b is 7 and c is 1. Our number is 8712.

Let us now do the case where ‘R’ is 9.

1000a + 100b + 10c + d = 9000d + 900c + 90b + 9a.

Rearrange that to be

991a + 10b = 890c + 8999d.

It follows using reasoning that we used in the previous case that d must be 1 and a must be 9, c must be 0, which gives b to be 8. Our number is 9801.

Try showing that these are the only solutions possible. This is actually easy to verify by writing some code in octave.