Professional Documents
Culture Documents
Five Digits Magic Prediction
Five Digits Magic Prediction
(https://www.cut-the-knot.org/manifesto/index.shtml)
For any integer A, let A' be obtained by writing A backwards. Compute B = |A - A'| and
C = B + B'.
Before reading further you may want to investigate the possible outcomes. The applet below is a calculator designed
specifically for that purpose. The blue numbers are clickable. The digits increase if clicked to the right of their vertical
axis, and decrease if clicked to the left of the axis.
(Note: The difference B = |A - A'| may come out with fewer than 4 digits. When this happens B is padded with the
necessary number of zeros to produce a 5-digit string which then is written backwards to give B'. For example, if
B = 87, B' = 78000 because the padded B is a string 00087.)
If you are reading this, your browser is not set to run Java
applets. Try IE11 or Safari and declare the site https:///www.cut-
the-knot.org as trusted in the Java setup.
https://www.cut-the-knot.org/Curriculum/Arithmetic/FiveDigitsPrediction.shtml 1/4
6/1/2019 Five Digits Magic Prediction
A 5-digit decimal number A could be written as A = 104a + 103b + 102c + 10d + e, giving A' = 104e + 103d + 102c + 10b
+ a. In what follows I shall always assume that a ≥ e. If that is not the case just swap A and A'. To start with, assume
a > e. Then
Note that, since the last term is negative, this is not the decimal representation of an integer. We shall try to manipulate
the terms so as to obtain a decimal representation.
The key case here is when b = d so that B = 104(a - e) + (e - a). Since e - a is negative we have to borrow from the first
term:
https://www.cut-the-knot.org/Curriculum/Arithmetic/FiveDigitsPrediction.shtml 2/4
6/1/2019 Five Digits Magic Prediction
Introduce x = a - e, u = b - d - 1, v = 9 + d - b, y = 10 + e - a. All are decimal digits; x + y = 10, u + v = 8. B = xu9vy;
B' = yv9ux,
There is only one case remaining: a = e. If b = d, the number is palindromic and the result is 0. Otherwise, A and A'
have the same ten thousand and unit digits. Assume that b > d. (If not, swap A and A'.) B is at most a 4-digit number
ending in 0: xyz0. Since we are dealing with 5-digit number, it needs to be padded to produce B' = zyx0; always
B + B' = 10890. This is because we could have dropped the first and the last digits of A (and also A') which would leave
3-digit numbers, with B = xyz and B' = zyx. As we know, for three digit numbers (https://www.cut-the-
knot.org/Curriculum/Arithmetic/S1089.shtml), B + B' = 1089. In the present, 5-digit case that number has to be
multiplied by 10, because actually B = xyz0 while B' = zyx0.
So, for the trick, it takes to remember only four cases - exactly as in the case of 4-digit numbers. But surely the
demonstration becomes more impressive.
The derivation goes through in other bases. If V and U denote the largest and the penultimate digits in some base, then
the algorithm applied to 5-digit numbers may only result in 0 (for palindromic numbers), 10VVUV (a > e, b = d), 10VUV0
(a > e, b > d), VV0VV (a > e, b < d), 10UV0 (a = e).
https://www.cut-the-knot.org/Curriculum/Arithmetic/FiveDigitsPrediction.shtml 3/4
6/1/2019 64888526 Five Digits Magic Prediction
https://www.cut-the-knot.org/Curriculum/Arithmetic/FiveDigitsPrediction.shtml 4/4