rec.puzzles Archive

Take any four-digit number (excluding 1111, 2222, 3333, etc.), sort its digits into descending order, make...

arithmetic/digits/kaprekar.6174 New

New entry, edited from material collected for the archive and not yet in a released version.

Problem

Take any four-digit number (excluding 1111, 2222, 3333, etc.), sort
its digits into descending order, make another number with the same
digits in ascending order, and subtract the second from the first.
Repeating this, after at most 7 times you get 6174 (and keep getting
it thereafter).  Why is it always 6174, and why does it never take
more than 7 steps?

-- Stephen H. Houchen <shhouche@aud.alcatel.com>
Show solution
Exhaustive enumeration is the way to go, but it's not as "exhausting"
as it seems at first.

   a    b     c     d
 - d    c     b     a
------------------------
(a-d) (b-c) (c-b) (d-a)

Notice that the result depends on only two quantities:  (a-d) and (b-c).
Since a >= b >= c >= d, (a-d) >= (b-c).  Excluding the trivial cases
where (a-d) = (b-c) = 0, (a-d) may be any integer from 1 through 9, and
(b-c) may be any integer from 0 through (a-d).

The digits of the result (after "borrowing") turn out to be:
If (b-c) = 0 :  (a-d-1) (9) (9) (10-a+d)
If (b-c) > 0 :  (a-d) (b-c-1) (9-b+c) (10-a+d)

In the first case, (a-d) = 9 gives the same answer as (a-d) = 2, 8 and 3
also give the same answer, etc., so that there are only 5 unique answers.
In the second case, (a-d) = 9 and (a-d) = 1 give the same answer, as do
(b-c) = 8 and (b-c) = 0, and so on, so that there are 25 unique answers.

[ Editor: in the second case (b-c) > 0; (b-c) = 8 gives the digits 7
and 1, which (b-c) = 2 also gives, so "(b-c) = 8 and (b-c) = 2" was
presumably meant. ]

So, there are only a total of 30 4-digit numbers that are solutions of
the first subtraction, and it's easy to show that each of those is part
of some sequence that leads to 6174 after at most 6 more iterations.

-- Angi Long <angilong@bach.seattleu.edu>, September 1994

[ Editor: from the entry "Kaprekar Routine" in Eric Weisstein's online
mathematics encyclopedia (Treasure Troves), 1996-7. ]

Kaprekar Routine

A routine discovered in 1949 by D. R. Kaprekar.  For any 4-digit
number n whose digits are not all the same, arrange the digits in
descending (n') and ascending (n'') order.  Now compute [ Editor: a
formula shown as an image, missing from the collected copy; from the
context, K(n) = n' - n''. ] and iterate.  In 7 or fewer steps, the
number 6174 will occur.  Furthermore, K(6174)=6174.  The routine can be
generalized to k digit numbers.  For a 3-digit number (whose digits are
not all the same) n in base r, there is a unique number
((r-2)/2, r-1, r/2) to which n converges in at most (r+2)/2 iterations
Iff r is Even.  For base 10, the Kaprekar constant 495 is reached in at
most 6 iterations.

See also Kaprekar Number

References

Eldridge, K. E. and Sagong, S.  "The Determination of Kaprekar
  Convergence and Loop Convergence of All 3-Digit Numbers."  Amer.
  Math. Monthly 95, 105-112, 1988.
Kaprekar, D. R.  "An Interesting Property of the Number 6174."  Scripta
  Math. 15, 244-245, 1955.
Trigg, C. W.  "All Three-Digit Integers Lead to..."  The Math. Teacher,
  67, 41-45, 1974.
Young, A. L.  "A Variation on the 2-digit Kaprekar Routine."  Fibonacci
  Quart. 31, 138-145, 1993.

-- Eric W. Weisstein <eww6n@virginia.edu>, 1997