A bit off topic, but I found this interesting math trick, called Kaprekar's constant.
If you take four digits and perform a series of simple functions upon them, the end result is 6174.
Basically:
- Sort the numbers from highest to lowest
- Subtract that from the numbers from lowest to highest
- Repeat this for the result until the final result is 6174
Example:
For the numbers 9452
9542 - 2459 = 7083 (now repeat the sorted subtraction using 7083)
8730 - 0378 = 8352
8532 - 2358 = 6174
You cannot enter four of the same digits, or all zero's, because it will result in zero. Three of the same digits, along with a +1 or -1 of that same digit (i.e. 1112, 2232, 4333) will result in 999 and finally in zero.
You can test using a quick script I put together in Perl, or you can try our online app.
Try It
Kaprekar's Routine Online | Kaprekar.pl
