# A mathematical magic trick

In case anyone’s wondering, here’s a magic trick that I did my class for future secondary math teachers while dressed as Carnac the Magnificent. I asked my students to pull out a piece of paper, a pen or pencil, and (if they wished) a calculator. Here were the instructions I gave them:

1. Write down just about any number you want. Just make sure that the same digit repeated (not something like 88,888). You may want to choose something that can be typed into a calculator.
2. Scramble the digits of your number, and write down the new number. Just be sure that any repeated digits appear the same number of times. (For example, if your first number was 1,232, your second number could be 2,231 or 1,322.)
3. Subtract the smaller of the two numbers from the bigger, and write down the difference. Use a calculator if you wish.
4. Pick any nonzero digit in the difference, and scratch it out.
5. Add up the remaining digits (that weren’t scratched out).

I asked my students one at a time what they got after Step 5, and I responded, as the magician, with the number that they had scratched out. One student said 34, and I answered 2. Another said 24, and I answered 3. After doing this a couple more times, one student simply stated, “My mind is blown.”

This is actually a simple trick to perform, and the mathematics behind the trick is fairly straightforward to understand. Based on personal experience, this is a great trick to show children as young as 2nd or 3rd grade who have figured out multiple-digit subtraction and single-digit multiplication.

I offer the following thought bubble if you’d like to think about it before looking ahead to find the secret to this magic trick.

What the magician does: the magician finds the next multiple of 9 greater than the volunteer’s number, and answers with the difference. For example, if the volunteer answers 25, the magician figures out that the next multiple of 9 after 25 is 27. So 27-25 = 2 was the digit that was scratched out.

This trick works because of two important mathematical facts.

(1) The difference $D$ between the original number and the scrambled number is always a multiple of 9. For example, suppose the volunteer chooses 3417, and suppose the scrambled number is 7431. Then the difference is

$7431 - 3417 = (7000 + 400 + 30 + 1) - (3000 + 400 + 10 + 7)$

$= (7000 - 7) + (400 - 400) + (30 - 3000) + (1 - 10)$

$= 7 \times (1000-1) + 4 \times (100-100) + 3 \times (10-1000) + 1 \times (1-10)$

$= 7 \times (999) + 1 \times (0) + 4 \times (-990) + 3 \times (-9)$

Each of the numbers in parentheses is a multiple of 9, and so the difference $D$ must also be a multiple of 9.

A more algebraic proof of (1) is set apart in the block quote below; feel free to skip it if the above numerical example is convincing enough.

More formally, suppose that the original number is $a_n a_{n-1} \dots a_1a_0$ in base-10 notation, and suppose the scrambled number is $a_{\sigma(n)} a_{\sigma(n-1)} \dots a_{\sigma(1)} a_{\sigma(0)}$, where $\sigma$ is a permutation of the numbers $\{0, 1, \dots, n\}$. Without loss of generality, suppose that the original number is larger. Then the difference $D$ is equal to

$D = a_n a_{n-1} \dots a_1a_0 - a_{\sigma(n)} a_{\sigma(n-1)} \dots a_{\sigma(1)} a_{\sigma(0)}$

$D = \displaystyle \sum_{i=0}^n a_i 10^i - \sum_{i=0}^n a_{\sigma(i)} 10^i$

$D = \displaystyle \sum_{i=0}^n a_{\sigma(i)} 10^{\sigma(i)} - \sum_{i=0}^n a_{\sigma(i)} 10^i$

$D = \displaystyle \sum_{i=0}^n a_{\sigma(i)} \left(10^{\sigma(i)} - 10^i \right)$

The transition from the second to the third line work because the terms of the first sum are merely rearranged by the permutation $\sigma$.

To show that $D$ is a multiple of 9, it suffices to show that each term $10^{\sigma(i)} - 10^i$ is a multiple of 9.

• If $\sigma(i) > i$, then $10^{\sigma(i)} - 10^i = 10^i \left( 10^{\sigma(i) - i} - 1 \right)$, and the term in parentheses is guaranteed to be a multiple of 9.
• If $\sigma(i) < i$, then $10^{\sigma(i)} - 10^i = 10^{\sigma(i)} \left( 1-10^{i-\sigma(i)} \right) = -10^{\sigma(i)} \left( 10^{i-\sigma(i)} - 1 \right)$, and the term in parentheses is guaranteed to be a (negative) multiple of 9.
• If $\sigma(i) = i$, then $10^{\sigma(i)} - 10^i = 0$, a multiple of 9.

$\hbox{QED}$

Because the difference $D$ is a multiple of 9, we use the important fact (2) that a number is a multiple of 9 exactly when the sum of its digits is a multiple of 9. Therefore, when the volunteer offers the sum of all but one of the digits of $D$, the missing digit is found by determining the nonzero number that has to be added to get the next multiple of 9. (Notice that the trick specifies that the volunteer scratch out a nonzero digit. Otherwise, there would be an ambiguity if the volunteer answered with a multiple of 9; the missing digit could be either 0 or 9.)

As I mentioned earlier, I showed this trick (and the proof of why it works) to a class of senior math majors who are about to become secondary math teachers. I think it’s a terrific and engaging way of deepening their content knowledge (in this case, base-10 arithmetic and the rule of checking that a number is a multiple of 9.)

As thanks for reading this far, here’s a photo of me dressed as Carnac as I performed the magic trick. Sadly, most of the senior math majors of 2013 were in diapers when Johnny Carson signed off the Tonight Show in 1992, so they didn’t immediately get the cultural reference.

## 3 thoughts on “A mathematical magic trick”

This site uses Akismet to reduce spam. Learn how your comment data is processed.