Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

6/1/2019 Five Digits Magic Prediction

(https://www.cut-the-knot.org/manifesto/index.shtml)

Five Digits Magic Prediction


A certain mathematical procedure applied to 3- and 4- digit numbers allows for an entertaining demonstration of
mathematical prowess. Even more spectacular, but not more difficult is to apply the same algorithm to 5-digit numbers.

The algorithm (https://www.cut-the-knot.org/WhatIs/WhatIsAlgorithm.shtml) is this:

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

What if applet does not run? (https://www.cut-the-


knot.org/HelpWithJava.shtml)
For 5-digit numbers, the algorithm may lead to one of 109989, 109890, 99099, 10890.

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

B = 104(a - e) + 103(b - d) + 10(d - b) + (e - a).

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:

B = 10000(a - e - 1) + 9990 + (10 + e - a).

Introduce x = a - e - 1 and y = 10 + e - a. Then B = x999y and B' = y999x, with x + y = 9, making

B + B ' = 10000(x + y) + 9990 + 9990 + (x + y) = 90000 + 19980 + 9 = 109989.

Next, assume b > d. In this case,

B = 10000(a - e) + 1000(b - d - 1) + 900 + 10(9 + d - b) + (10 + e - a).

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,

so that B + B' = 109890.

If d > b, we proceed differently:

B = 10000(a - e) + 1000(b - d) + 10(d - b) + (e - a)


= 10000(a - e - 1) + 1000(10 + b - d) + 10(d - b - 1) + (10 + e - a).
Let x = a - e - 1, u = 10 + b - d, v = d - b - 1, y = 10 + e - a. All are decimal digits; x + y = 9; u + v = 9; B = xu0vy;,
B' = yv0ux;

B + B' = 10000·9 + 1000·9 + 10·9 + 9 = 99099.

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).

1. 1089 and a Property of 3-digit Numbers (https://www.cut-the-


knot.org/Curriculum/Arithmetic/S1089.shtml)
2. Four Digits Magic Prediction (https://www.cut-the-
knot.org/Curriculum/Arithmetic/FourDigitsPrediction.shtml)
3. Five Digits Magic Prediction

|Activities| (https://www.cut-the-knot.org/Curriculum/index.shtml) |Contact| (https://www.cut-the-


knot.org/MailNotificationPage.shtml) |Front page| (https://www.cut-the-knot.org/front.shtml) |Contents|
(https://www.cut-the-knot.org/content.shtml) |Arithmetic| (https://www.cut-the-knot.org/arithmetic.shtml)

Copyright © 1996-2018 Alexander Bogomolny (https://www.cut-the-knot.org/index.shtml)

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

You might also like