The Mathematics Behind 6174
Kaprekar’s routine produces a surprising result from trivially simple steps. Underneath the trick, however, is some genuinely interesting number theory. This page walks through why 6174 is special, why the routine converges, and what happens when you change the digit count or the number base.
6174 as a Fixed Point
A fixed point of a function f is a value x for which f(x) = x. Applied to Kaprekar’s routine, a fixed point is a number that, when you rearrange and subtract, produces itself.
For 6174, the descending arrangement is 7641 and the ascending arrangement is 1467. Subtracting:
7641 − 1467 = 6174
So 6174 maps to itself. The routine has found its destination and cannot leave.
In 1981, G. D. Prichett, A. L. Ludington, and J. F. Lapenta proved formally that 495 (3 digits) and 6174 (4 digits) are the only cases in base 10 where every valid starting number converges to a single Kaprekar fixed point. Some other digit lengths (6, 8, 9) have multiple fixed points and so lack a single universal Kaprekar constant; others (2, 5, 7) enter cycles rather than stopping at a fixed value.
Why Every Result is a Multiple of 9
Here is a small but elegant observation. At every step of Kaprekar’s routine, the result is a multiple of 9.
The reason is straightforward. Rearranging the digits of a number does not change its digit sum — the sum of its digits. And two integers with the same digit sum leave the same remainder when divided by 9. So when you subtract one from the other, you are subtracting two numbers with the same remainder modulo 9, and the difference is necessarily divisible by 9.
This is why, when you watch Kaprekar’s routine in action, every intermediate result is something like 3087, 8352, 6264, 6174 — all multiples of 9. This observation alone shrinks the search space of possible results dramatically, which is part of why convergence is so fast.
Proof Sketch: Why Convergence is Guaranteed
A full proof that every four-digit non-repdigit converges to 6174 in at most seven steps is a case-analysis argument: you enumerate the possible digit patterns and show that each reaches 6174.
The key insight is that after one iteration, the result is always one of a relatively small set of multiples of 9 with particular digit patterns. After two iterations, the set shrinks further. By iteration seven, every starting point has funnelled into 6174, with no exceptions.
This is not an aesthetic proof but a combinatorial one. It works because four-digit numbers with at least two distinct digits form a finite, well-behaved set, and the Kaprekar map on that set has a single attractor.
Other Properties of 6174
The number 6174 has several curious properties in its own right:
- Factorisation: 6174 = 2 × 3² × 7³. The cube of 7 is central.
- 7-smooth: None of its prime factors exceed 7.
- Harshad number: 6174 is divisible by the sum of its digits. 6 + 1 + 7 + 4 = 18, and 6174 ÷ 18 = 343 (which is 7³).
- Powers of 18: 6174 = 18³ + 18² + 18 = 5832 + 324 + 18. The digit sum of 6174 is itself 18, which makes this coincidence particularly pleasing.
- Sum of squared prime factors: The squared prime factors of 6174 are 2², 3², 3², 7², 7², 7². Their sum is 4 + 9 + 9 + 49 + 49 + 49 = 169, which is 13².
These properties are not responsible for 6174’s role as a Kaprekar constant — that role comes from its behaviour under the digit-rearrange-and-subtract map. But they make 6174 a quietly rich number in its own right.
What About Other Digit Lengths?
Kaprekar’s routine can be applied to numbers of any digit length. The behaviour varies:
- 3 digits: Always converges to 495 (in at most 6 iterations). See the 495 solver.
- 4 digits: Always converges to 6174 (in at most 7 iterations). This is the case covered on this site’s homepage.
- 2, 5, and 7 digits: No single fixed point. The routine enters cycles. For 2 digits, the cycle is
9 → 81 → 63 → 27 → 45 → 9. - 6 and 8 digits: Two fixed points each. For 6 digits the constants are 549945 and 631764.
- 9 digits: Two fixed points: 554999445 and 864197532.
This irregular pattern is itself a topic of active recreational-maths interest. Why do 3 and 4 digits get single clean constants while most other lengths do not? The answer lies in combinatorial constraints that are easy to state but tedious to enumerate.
Bases Other Than 10
Kaprekar’s routine is base-dependent. In base 4, for example, numbers of the form 3021, 310221, 31102221, and so on are fixed points. The pattern generalises: in base b, certain digit strings serve the same role that 6174 serves in base 10.
This base-dependence is part of what makes Kaprekar’s routine such a useful pedagogical example. It is not a deep theorem about integers — it is a statement about how we write integers. Change the notation and you change the fixed points.
Further Exploration
- Try the interactive solver and watch the convergence live
- Read worked examples of the routine in action
- Learn about the mathematician who discovered 6174