The Indian mathematician D. R. Kaprekar spent many happy hours during his youth solving mathematical puzzles. He graduated from Fergusson College in Pune in 1929 and became a mathematical teacher at a school in Devlali, north-east of Mumbai.

Kaprekar is remembered today for a range of curious mathematical patterns that he discovered. The best known is probably that related to the number 6174, sometimes called Kaprekar’s constant. If we take the four digits of 6174 and form two new numbers by arranging them in descending and ascending order, we get 7641 and 1467. Subtracting, we get 7641 – 1467 = 6174, the number we started from.

This is no great surprise. What is surprising is that, starting from any four-digit number (other than “repdigits” like 3333) and repeating the same process, we always arrive at 6174.

Let us take 1234 and apply the process:

4321 – 1234 = 3087

8730 – 0378 = 8352

8532 – 2358 = **6174**

Again, if we choose the current year, 2018, we get the sequence

8210 – 0128 = 8082

8820 – 0288 = 8532

8532 – 2358 = **6174**

The iterative process always converges to Kaprekar’s constant in, at most, seven steps. Once this fixed point is reached, the process will simply cycle, yielding 7641 – 1467 = 6174.

There are analogous results for numbers with a different number of digits. For three-digit numbers (excluding repdigits) the fixed point is **495**, which is reached in at most six iterations (see figure above). For numbers with other digit lengths, Kaprekar’s process may either terminate at a fixed point or enter a cycle covering several values. The behaviour may depend on the starting number. For example, two digit numbers with distinct digits always reach the cycle { 09, 81, 63, 27, 45 } and repeat it forever.

The British mathematician G. H. Hardy had little time for “trivial mathematics”. He would probably have dismissed Kaprekar’s finding as “intolerably dull”. But for us lesser morals, such results are a source of innocent merriment.