March 14th (3/14) is world pi day.

On March 14 2010 a mathematician and a magician teamed up to perform what they believed to be the world's largest live magic trick. The trick involved a thousand volunteers from the around the world who, using free choice, each came up with a number that was only known to themselves. And although the volunteer might be on the other side of the globe, the mathematician and the magician were able to read their mind and tell them which number they had chosen.

I was the mathematician in this partnership. For me mathematics is full of colour and beauty and magic. I work with the Millennium Mathematics Project, of which Plus is also a part. I travel the country, and the world, in the attempt to bring mathematics to life. And I do much the same in my free time, making videos online. It was one of my followers here who suggested a massive online event: the world's largest magic trick.

Soon it would be World Pi Day, a day to celebrate all things mathematical. Pi Day happens every year on 14th March, the date being 03.14 — the first few digits of pi. It is most often celebrated by baking a large number of pies. So what better date to perform my mathematical magic trick — an event we called Pi Day Magic 2010.

I performed the trick with Brian Brushwood, US magician and host of his own Internet series Scam School. All our viewers had to do was to follow the event on Twitter using the hashtag #pidaymagic, where they would be able to see the trick unfold from wherever they were in the world.

And now you can learn how to perform the trick yourself (if you don't feel like reading, you can watch a video revealing the magic on the Pi Day Magic website.). It goes like this:

  • First, take a calculator. Any calculator, maybe the one on your phone, or even Google will do.
  • Next, ask your volunteer to start multiplying single digit numbers of their choice, making sure they get a good mix of numbers as they go. So that might be something like 2 × 6 × 5 × 6 × ... .
  • Tell the volunteer to stop when the result is a number that is six or seven digits long.

Your volunteer has a completely free choice when picking the single-digit numbers in the multiplication. And now this is where the magic starts. You ask your volunteer to look at the number they've made, to pick one of its digits, and to keep it to themselves. This is their chosen number. Now ask them to give you the remaining digits and, here is the killer, they may do so in any order they like.

Now ask them to concentrate on their chosen number.

Remember, not only did your volunteer have a completely free choice when multiplying single digits, generating a random number, but they also had a free choice when recalling the remaining digits. Yet, you are able to read the volunteer's mind, and pick out their chosen number.

How is it done? With a little mathematical trick involving the magic number 9.

If you remember your nine times table, then you know that the multiples of 9 are 9, 18, 27, 36 and so on. You can already see that the digits of these multiples always add up to 9, i.e. 2 + 7 = 9, 3 + 6 = 9, etc. If the digital sum is over 9, as happens with the number 99, then the digits add up to a multiple of nine, in this case 18.

It can be proved (see below) that the digital sum of all multiples of 9 always adds up to a multiple of 9. The converse is also true: if the digital sum of a number is a multiple of 9, then the number is also a multiple of 9.

So, by adding up the digits of 6727374 to get 36, I can instantly tell that it is a multiple of nine.

How does this help with our trick? Well, when I asked you to multiply single digits, I was relying on you making a multiple of nine, by either hitting the 9 at least once, or maybe hitting 3 or 6 twice. Either way, we instantly have a multiple of 9.

And, assuming that we do have a multiple of 9, my method allows me to tell you the missing digit.

For example,

4 × 6 × 8 × 7 × 3 × 2 × 7 × 5 = 282240.

Since our multiplication has a 6 and a 3, this is a multiple of 9.

There's magic in the number 9.

The digital sum adds up to 18, a further multiple of 9, as expected. If our volunteer chooses the number 8 as their special number, they will return the digits 2 2 2 0 4. Since these add up to 10, we may assume the missing digit is 8.

This is a brilliant and effective mathematical trick, although my presentation has two drawbacks.

First, we cannot tell the difference between a 0 and a 9. So in the example above, the volunteer may return the digits 2 2 2 8 4. These add up to 18, and we cannot tell if the chosen digit was a 0 or a 9 (to make a digital sum of 27).

Here a little patter is needed. Ask your volunteer to concentrate on their number — are they thinking of nothing? A knowing smile from your volunteer will tell you they are thinking of 0, otherwise it's a 9. Or more directly, ask them if their number is even, if they say no, then they chose the number 9, if they looked slightly confused, it will a 0. (However they need not be confused 0 is an even number).

And secondly, what if the volunteer doesn't hit a 9 or a pair of 3s or 6s? The resulting number will not be a multiple of 9. This might happen 10% of the time, and the trick will not work. In my instructions I ask the volunteer to mix up the numbers, possibly implying this makes the trick harder. However, if the trick still fails it can be saved.

Just ask your volunteer to reverse their number and then subtract their original number, this will instantly give you a multiple of 9, and you can try again.

Here's the maths

So how can we be so sure that a multiple of 9 always gives a digital sum which is also a multiple of 9?

To understand this, think about what happens when you add 9 to any number. If the last digit of the number is a 0, for example if the number is 10, then adding 9 amounts to changing this 0 to a 9, 10+9=19, so the digital sum increases by 9.

Now suppose that the last digit of the number is not 0, for example take the number 751. Adding 9 is the same as adding 10 and then subtracting 1. Subtracting 1 reduces the last digit by 1: 751-1=750. Unless the second-to-last digit is a 9, adding 10 increases it by 1: 750+10=760. So overall the digital sum does not change at all, as you have reduced one digit by 1 and increased another by 1.

Maths can be your crystal ball.

And what if the second to last digit is a 9? Or, more generally, what if there is a whole string of 9s to the left of the last digit, as in the number 199992? In this case, adding 10 will change all these 9s to 0s and then add 1 to the first digit after the string (reading from right to left) that's not a 9: 199992+10=200002.

So when adding 10 we lose several lots of 9 from the digital sum (however many 9s there are in the string) and add 1. But the 1 you have added is cancelled out when you subtract 1, which has the effect of reducing the last digit by 1: 200002-1=200001. So adding 9 has the effect of reducing the digital sum by a multiple of 9.

Now suppose that the number is itself a multiple of 9 — this means that it can be written as n×9 for some whole number n: 18=2×9, 27=3×9, 36=4×9, etc. We can get to our number by starting from 9 and then adding (n-1) lots of 9: 18=9+9, 27=9+2×9, 36=9+3×9, etc. The digital sum of the initial 9 is of course 9, and since adding 9s only ever changes the digital sum by multiples of 9, the digital sum of n×9 must be a multiple of 9. QED

We've just shown that every multiple of 9 has a digital sum which is also a multiple of 9, but can we prove the converse — that every number whose digital sum is a multiple of 9 is itself a multiple of 9?

First notice that however many digits our number, call it a, has to start with, by repeatedly subtracting 9s we eventually arrive at a single digit number r, which is greater than 0:

For example, 47-9-9-9-9-9=47-5×9=2, so in this case r=2.

In general we can write this as a-n×9=r, where n is some whole number. (The number r is actually the remainder of a when dividing by 9.)

By a reversal of the argument above, we know that subtracting 9s can only change the digital sum by a multiple of 9. So if the digital sum of the original number a was a multiple of 9, then the digital sum of r must also be a multiple of 9. But r is a single digit number, so the only possibility is that r=9.

So we have a-n×9=9, so a=(n+1)×9 — a is a multiple of 9, as required. QED

We have just proved a beautiful and simple result from number theory, which illustrates the power and elegance of mathematics. It can also be used for cheap tricks.

Read more about...
  • Want facts and want them fast? Our Maths in a minute series explores key mathematical concepts in just a few words.