why this puzzle works?

185 Views Asked by At

Think of a positive integer, call it X. Shuffle the decimal digits of X, call the resulting number Y. Subtract the smaller of X,Y from the larger, call the difference D. D has the following property: Any non-zero decimal digit of D can be determined from the remaining digits. That is, if you ask someone to hide any one of the non-zero digits in the decimal representation of D, then you can try to impress the other person by figuring out the hidden digit from the remaining digits. How is this done? Why does it work?

2

There are 2 best solutions below

0
On

If you're interested in the concept, type in the phrase "casting out nines" in your search engine of choice.

In the example you gave, the basic idea is that you know that $X$ and $Y$ have the same remainder when divided by 9 since they share the same digits1. Hence, the difference must be a multiple of 9.

Since we know the sum of the digits of any multiple of 9 is itself a multiple of 9, you can deduce the last digit. (In the case that the sum is itself a multiple of 9, you can use the fact that they hid a non-zero digit to deduce that the remaining digit is in fact a 9.)


1 To see this, note that any power of 10 has remainder 1 when divided by 9, and use modular arithmetic.

0
On

The short short version is that this is an artifact of the idea of casting out nines: the sum of a number's digits gives the same remainder on division by 9 that the original number does. For instance, $431=9\times47+8$, and $4+3+1=8$. Since X and Y have the same digits, they have the same digit-sum, so they have the same remainder on dividing by 9. But this means that their difference D is a multiple of 9; and that means that D's digit-sum is a multiple of 9 (since it must give the same remainder on dividing by 9 that D does). When a non-zero digit is hidden, it'll reduce the digit-sum of D by that much, so all you have to compute is the digit from 1—9 (and note that there will always be a unique digit - this is why the 'nonzero' restriction is there, because otherwise there'd be no way to tell a zero from a nine) to add to the digit-sum of D to bring it up to a multiple of 9.