Explore modules

Kaprekar Four-Digit Attractor

Sort four digits in opposite orders and subtract: thousands of starting numbers fall into the same 6174 attractor.

Free theory article

Sort four digits in opposite orders and subtract: thousands of starting numbers fall into the same 6174 attractor.

Concept & interpretation

The Kaprekar routine for four-digit numbers is a finite dynamical system where every initial number, except those with four identical digits, eventually reaches the attractor 6174 (Kaprekar's constant). The routine involves sorting the digits of the number in descending and ascending order, and subtracting the smaller from the larger, padding with leading zeros to maintain exactly four digits.

Experiment

In the interactive module, follow these steps to see the Kaprekar routine in action:

  1. Select a string from the "Initial digits" control to pick a starting number.
  2. Select a number from the "Inspection step" control to view the subtraction at a particular iteration.
  3. Observe the "Current four digits" text to trace the trajectory.

Read the full free theory article