Dattatreya Ramchandra Kaprekar (1905-1986) was an Indian mathematician.
In the 1940's, he discovered an intriguing property of the number 495 (now callled the Kaprekar constant).
We start by choosing a 3 digit number (do NOT choose numbers in which all 3 digits are equal.)
Arange the digits to make
1) a larger number by rearranging those digits (from largest to smallest)
and then we make
2) a smaller number by rearranging those digits (from smallest to largest)
For example, let's start with 671.
1) We make the larger number by rearranging the digits 761.
2) We rearrange those digits to make the smaller number 167.
Subtracting the second number from the first we get
761 - 167 = 594
With 594, we repeat the steps we just followed:
954 - 459 = 495
After just two steps, we reach 495 and after that, the sequence just keeps repeating.
Kaprekar stated that when any 3 digit number is subjected to the "Kaprekar algorithm"
six will be the maximum number of steps and the final number will be 495.