There's a number trap, and almost every four-digit number falls into it. The trap is 6174. You can't escape it, and it only takes a few steps to get caught.
The Trap Recipe
Here's how to set the trap. You only need a pencil, some paper and a four-digit number. (Try your birth year, or the last four digits of your phone number.)
- Pick a four-digit number. The digits can't all be the same (so no 3333).\
- Shuffle the digits into the biggest number you can make.\
- Shuffle them again into the smallest number you can make.\
- Subtract the small one from the big one.\
- Do the same thing with your answer. Keep going!
Before you read on: where do you think you'll end up?
Watch the Trap Snap Shut
Let's start with 3524.
Biggest: 5432. Smallest: 2345. 5432 − 2345 = 3087
Biggest: 8730. Smallest: 0378. 8730 − 378 = 8352
Biggest: 8532. Smallest: 2358. 8532 − 2358 = 6174
Three steps and we're at 6174! Now let's try 1000. (Zeros count as digits, so the smallest shuffle is 0001.)
1000 − 0001 = 0999
9990 − 0999 = 8991
9981 − 1899 = 8082
8820 − 0288 = 8532
8532 − 2358 = 6174
A totally different journey, the same destination. And once you're in the trap, you can't get out:
7641 − 1467 = 6174
It turns into itself, forever. 6174 is the maths version of quicksand.
Wait, Every Number Gets Trapped?
We asked a computer to check all the four-digit numbers, from 0000 to 9999. Here's what it found:
9,990 numbers fall into the trap.
10 numbers don't: the boring ones with four identical digits (0000, 1111, 2222... up to 9999). They turn into 0 straight away, and 0 stays 0.
And nobody takes more than 7 steps. The most popular route is exactly 3 steps, with 2,400 numbers taking it.
Why Does This Happen?
Honestly? Nobody has a one-line explanation. People first found this by playing with numbers, and the clearest way to be sure is to check every possible number, which a computer does in a blink.
But here's a sneaky clue. Look at the answers we got along the way: 3087, 8352, 6174. Every single one is in the 9 times table! (3087 = 9 × 343, 8352 = 9 × 928, 6174 = 9 × 686.) That's no accident. Shuffling the digits of a number never changes what the digits add up to, so the big number and the small number always differ by a multiple of 9. That squeezes the possible answers into a much smaller group, which is part of why they all end up in the same place.
Try It Yourself
Does the trap work for three-digit numbers too? Let's try 123:
321 − 123 = 198
981 − 189 = 792
972 − 279 = 693
963 − 369 = 594
954 − 459 = 495
Three-digit numbers get trapped at 495 instead. Pick your own three-digit number and see if you land there. Then try it on a friend as a magic trick: have them pick a secret number, do the steps, and tell them what they've got before they say it!
Who Found This Trap?
It's named after an Indian maths teacher called D. R. Kaprekar. He was mostly self-taught and spent his whole career teaching in a town called Devlali, but he loved playing with numbers. He found this trick in 1946 and told the world about it in 1949 at a maths conference in Madras.
The OddMaths Takeaway
It looks like shuffling and subtracting should send numbers all over the place. Instead, almost every one gets funnelled down the same slide into 6174. No number looks less magical than 6174, but it's the one this trick can't get away from.