*Kaprekar's process* is a

mathematical phenomenon discovered by

Indian mathematician,

Shri Dattathreya Ramachandra Kaprekar in

1949 and published in

1955. He states:

*"Start with a four-digit number whose digits are not all equal, arrange the digits in ascending and descending order, subtract and repeat the process. Then the process terminates on the number 6174 after seven or fewer steps."*
**A sample walkthrough:**

Let's start with an arbitrarily chosen number, 2981.

Sorting the digits in both ascending and descending order yields 1289 and 9821.

9821-1289=8532

Sorting the digits again yields 2358 and 8532.

8532-2358=6174

The result is as predicted.

**Some cycles for Kaprekar's process:**

2: 9 -> 81 -> 63 -> 27 -> 45 -> 9
3: 495
4: 6174
5: 53955 -> 59994 -> 53955
61974 -> 82962 -> 75933 -> 63954 -> 61974
62964 -> 71973 -> 83952 -> 74943 -> 62964
6: 420876 -> 851742 -> 750843 -> 840852 -> 860832 -> 862632 -> 642654 -> 420876
549945
631764
7: 7509843 -> 9529641 -> 8719722 -> 8649432 -> 7519743 -> 8429652 -> 7619733 -> 8439552 -> 7509843