Professional Documents
Culture Documents
Four Digits Magic Prediction
Four 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 4-digit string which then is written backwards to give B'. For example, if
B = 87, B' = 7800 because the padded B is a string 0087.)
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/FourDigitsPrediction.shtml 1/4
6/1/2019 Four Digits Magic Prediction
A 4-digit decimal number A could be written as A = 1000a + 100b + 10c + d, giving A' = 1000d + 100c + 10b + a.
Assume that a ≥ d. (If that is not true just swap A and A'.) We first consider the case where a and d are different: a > d.
Then
The key case here is when b = c so that B = 1000(a - d) + (d - a). Since d - a is negative we have to borrow from the
first term:
and
https://www.cut-the-knot.org/Curriculum/Arithmetic/FourDigitsPrediction.shtml 2/4
6/1/2019 Four Digits Magic Prediction
so that B + B' = 9999.
How we obtain the last possible outcome? There is only one case remaining: a = d. If b = c, the number is palindromic
and the result is 0. Otherwise, A and A' have the same thousand and unit digits, so that necessarily B is a 3-digit
number ending in 0: xy0, with x + y = 9. Since, at this stage, we are dealing with 4-digit number, it needs to be padded
to produce B' = yx0 (xy0 → 0xy0 → 0yx0 → yx0), giving B + B' = 990.
It looks like 4-digit numbers allow for a presentation of spectacular mental math. Ask your audience to produce a 4-digit
number. If a = d, the result is either 0 or 990. If need be, read it backwards to have a > d. Then b > c gives 10890, b = c
leads to 10899, and b < c will result in 9999. Not much to remember. The audience will be stunned by your ability to first
subtract two 4-digit numbers and then add other two in under instantaneously.
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 palindormic numbers), 10VUV (a > d, b = c), 10UV0
(a > d, b > c), VVVV (a > d, b < c), VV0 (a = d).
64888440
https://www.cut-the-knot.org/Curriculum/Arithmetic/FourDigitsPrediction.shtml 3/4
6/1/2019 Four Digits Magic Prediction
https://www.cut-the-knot.org/Curriculum/Arithmetic/FourDigitsPrediction.shtml 4/4