Kaprekar's routine 6174

The above process, known as Kaprekar's routine, will always reach 6174 in at most 7 iterations.


====================

Once 6174 is reached, the process will continue yielding 7641 – 1467 = 6174. For example, choose 3524:

5432 – 2345 = 3087
8730 – 0378 = 8352
8532 – 2358 = 6174

The only four-digit numbers for which Kaprekar's routine does not reach 6174 are repdigits such as 1111, which give the result 0 after a single iteration. All other four-digits numbers eventually reach 6174 if leading zeros are used to keep the number of digits at 4:

2111 – 1112 = 0999
9990 – 0999 = 8991 (rather than 999 – 999 = 0)
9981 – 1899 = 8082
8820 – 0288 = 8532
8532 – 2358 = 6174

9831 reaches 6174 after 7 iterations:

9831 – 1389 = 8442
8442 – 2448 = 5994
9954 – 4599 = 5355
5553 – 3555 = 1998
9981 – 1899 = 8082
8820 – 0288 = 8532 (rather than 882 – 288 = 594)
8532 – 2358 = 6174