The problem statement from the Ole Miss Problems of the Week page is:

Determine all five-digit numbers that are reversed when multiplied by four.

Well, that is certainly a simple enough problem, if we assume that a number being “reversed” means the digits are reversed in order. The obvious way to answer this question (obvious given that we have a programmable CFX-9850G or FX-7400G calculator close to hand) is to program in a simple search.

The program needs to look at five-digit numbers. The first five-digit number is 10000, so that is clearly the low bound on the search space. Now, these numbers have to stay five-digit numbers when they are multiplied by four: if multiplying the number by 4 gives a six-digit number, pretty clearly that six-digit number is not going to be the reverse of the five-digit number. So the other end of the search space is 25000 (or more precisely 24999), the largest five-digit number that stays five digits when multiplied by four.

Reversing the digits is easy enough. We can pop digits off the number, rightmost first, and put them on another number, leftmost first.

That is enough planing to get out our trusty calculator and write our program, as always available here in text or in a text file with .CAT file contents:

; Variables: ; A is number being tested ; B is a copy of A (used up in producing C) ; C is reversal of A ; Symbols: ; -> is assignment arrow ; < is less than comparision ; <> is not equal comparison ; / is division operator ; _ is display triangle 10000->A ; The first number is 10000 While A<25000 ; Loop until all possibilities are checked A->B ; Copy A to B 0->C ; Zero reversed copy While B<>0 ; While there is anything left to reverse 10C+10Frac (B/10)->C; Stick bottom digit from B onto C Int (B/10)->B ; Remove bottom digit from B WhileEnd ; [End of while anything left to reverse] If C=4A ; Test whether reversal is 4 times number Then A_ ; If so, report number IfEnd ; [End of test whether reversal is...] A+1->A ; Go on to next number to test WhileEnd ; [End of loop until all possibilities are checked] "Done" ; Report we are done

So we run the program, and wait for the calculator to announce the answers to the problem.

While the calculator is crunching along, though, we can think about the problem. There is no rule against thinking while the program is running, after all.

Suppose A is the five digits *abcde*; then 4A is the five
digits *edcba*.
We already know the digit *a* is 1 or 2.
Looking at the last digit, *a* is also the ones place of
4*e*.
But 1 cannot be the ones digit of 4*e* for any *e*, so
*a* has to be 2, so *e* has to be one of 3 (3×4 =
12) or 8 (8×4 = 32).
But *e* has to be at least 8, since *e* is 4*a*
plus some carry in.
So we know *a* has to be 2 and *e* has to be 8.

So the number we have is of the form 2*bcd*8, and 4 times
that is 8*dcb*2.
Looking at just the middle three digits, we have 4×*bcd*+3
= *dcb*.
(The 3 is the carry in from the 8 in the one’s digit.)
Looking at just the one’s digit of this, we have
4×*d*+3 = *b* (mod 10).
We also know 4×*b* does not carry, so *b* is at most 2.
We also know 4×*d* is even and 3 is odd, so *b*, their
sum, is odd.
The only odd digit less than 2 is 1, so *b* is 1.
Playing with the numbers shows the only possible values for *d*
are 2 and 7.
So the number we have is 21*cd*8, and 4 times that is
8*dc*12.
Now the thousands of 4×21*cd*8 is going to be 84 plus whatever
carry in there is, so *d*, the thousands digit of the product, is
at least 4.
Since *d* must be either 2 or 7, it is therefore be 7.

So by now we know the number is 21*c*78, and 4 times that
number is 87*c*12. Well, 4 times 78 is 312, so the carry
into the hundreds place in the multiplication is 3.
And 4 times 21 is 84, so the carry out of the hundreds place in
the multiplication is 3.
So we know 4×*c*+3 = 30+*c*,
or 3×*c* = 27, or *c* = 9.

The only number meeting the criteria is therefore 21978. A quick multiplication as a check shows that indeed 4×21978 = 87912.

Something, however, bothers us about that 9.
The carry into the hundreds place — the 3 — was the
same as the carry out of the hundreds place.
That means if the 9 weren’t there, the reversal property
would still work.
A quick check shows yes, 2178×4 = 8712; and all the
figuring before still works, so this is the *only* four
digit number which when multiplied by 4 has its digits reversed.
And if the 9 there had been two 9s, each would have a carry in
of 3, a carry out of 3, and leave a 9 in the final answer.
A quick check shows yes, 219978×4=879912, 2199978×4
= 8799912, and so forth.
So we have discovered a complete family of numbers which when
multiplied by 4 reverse their digits.
Are these the only numbers that do this?
If there are *k* digits in the middle, and the value of
the middle digits is *x*, then needing a carry of 3 in
and a carry of 3 out means

4x + 3 = 3×10^{k} + x, or

3x = 3(10^{k}-1), or

x = 10^{k}-1

So yes, the *only* numbers which when multiplied by 4
reverse their digits are of the form 21*x*78 where *x*
is a string of 9s.

Well, actually, the know all numbers *with at least four
digits* that reverse their digits when multiplied by four.
The figuring for *a*, *b*, *d*, and *e*
assumed at least four digits.
Are there any one digit numbers that are the same after being
multiplied by four?
It would need 4*a*=*a*, or 3*a*=0, or a=0.
Zero is not really a one digit number: it is a zero digit number.
Two digits?
The possibilities are 14 and 28, and neither of them work, so no,
no two digit number works.
Three digits?
It would be 2*b*8, and would need 4*b*+3=*b*, or
*b*=-1, so no, no three digit number works.
So we actually do now know *all* numbers which reverse their
digits when multiplied by four.

And about this time, the calculator comes up with its first answer:

21978

— which we knew already. A while later, the calculator comes up with:

Done

— which we also knew already.

In fact we now know *all* numbers which when multiplied
by 4 reverse their digits, and that is something the calculator
could never tell us.

I guess thinking won out over calculating again.

[ Previous page | Top of page | Next page ]

Copyright © 2001 Brian Hetrick

Page last updated 25 November 2001.