Richard E. Schwartz
Department of Mathematics
Brown University
Box 1917
151 Thayer Street
Providence, RI 02912
USA
Start with four digits, arrange them in both descending and ascending order, subtract, and repeat.
This simple process is known as the Kaprekar routine,
famous in base ten for sending every nonconstant four-digit string to

.
We show that in every odd base

, the four-digit Kaprekar map has an unexpectedly rigid structure.
After at most three iterations,
every nonconstant orbit enters an explicit triangular region
and on this region the map is conjugate to projective doubling:
This gives a complete finite description of all nonconstant terminal cycles,
including an explicit formula for their lengths and counts.
In particular, the longest terminal cycle has length at most

,
and equality can occur only when

is prime.
For primes

, equality occurs precisely when the least positive

with

(mod

) is

.
The results proved here were first formulated by Schwartz and Thakur.
As a test case for AI-assisted formal mathematics,
AxiomProver produced Lean/mathlib formalizations of these results.
Received June 18 2026; revised versions received August 1 2026; August 11 2026.
Published in Journal of Integer Sequences,
August 12 2026.