*Becoming an expert at mental maths is just a matter of knowing the tricks and that just means learning a bunch of cunning algorithms. Here are some cunning algorithms around the number 9.*

We cover:

- An introduction to algorithms
- Learn an algorithm to work out 9 times table multiplications
- Learn how to add 9 easily
- Efficiency and choosing algorithms
- Pattern matching
- Generalisation
- Proving algorithms always work
- Practical use of algebra

Its good to learn your times tables by heart, not least because knowing them makes division easier. While you do learn them its also nice to know algorithms that help work them out, and as a backup when your mind goes blank. The 9-times table is my favourite as it has a beautiful pattern behind it.

In primary schools, pupils have long learnt about algorithms, but just haven’t called them that. In particular, learning basic arithmetic is all about learning algorithms. Every one takes it for granted that if you can learn these algorithms then by following the steps blindly you will always get the right answer (even if you don’t understand why they work). That is exactly what computers do.

Here are some algorithms that give you answers to the nine times table problems.

**The repeated addition algorithm**

Most people start out with a repeated addition algorithm as the way of working out multiplications they haven’t yet learned. Multiplication is just adding a number repeatedly after all. What is 2 times 9? Add 9 to 9 so 18. What is 3 times 9? Just add on another 9 to 18 so 27…

The problem with this of course is it is very slow, especially if you do addition by counting (eg on your fingers). We really want a fast algorithm so we can still get answers quickly. Efficiency of algorithms (ie how fast they are) matters whether the algorithms are for computers or for humans to follow.

You can do it more quickly with a little optimisation. If you can remember 5×9= 45, and 10×9 = 90 then you can get the others by just adding or subtracting 9 to those answers up to times.

There are much faster algorithms.

**The 9 times table finger algorithm**

The neatest 9-times table algorithm uses your fingers in a cunning way.

*To work out 9 times N (or N times 9) for any N up to 10 *(eg 9 times 3 or 3 times 9)

- Hold up all ten fingers on your hand
- Count N fingers from the left
- Lower that finger
- Read off the answer from your fingers
- The number of fingers
**before**that lowered finger give you the number of tens in the answer - The number of fingers
**after**that lowered finger give you the number of ones in the answer

- The number of fingers

So for example: to work out 9 times 3 (N is 3): lower the third finger from the left. There are 2 fingers raised before it, and 7 raised after it so the answer is 27.

Try the algorithm yourself on other examples. Can you work out why it works?

**The 9 times table simple subtract-1 algorithm**

This different algorithm is just a variation of the finger one, using the same underlying pattern

*To work out 9 times N (or N times 9) for any N up to 10*

- Subtract 1 from N and write the result in the tens column of the answer
- Subtract the answer of step 1 above from 9 and write the result in the ones column of the answer

So for example: to work out 9 times 3:

- Calculate 3-1=2 so write 2 in the tens column of the answer
- Calculate 9-2=7 so write 7 in the ones column of the answer

The answer is 27.

**A variation on the algorithm**

Perhaps you find subtracting numbers from 10 easier than subtracting from 9. Knowing your number bonds (pairs that add to 10 is important for other things too). Here is another variation:

*To work out 9 times N (or N times 9) for any N up to 10*

- Subtract 1 from N and write the result in the tens column of the answer
- Subtract N from 10 and write the result in the ones column of the answer

So for example: to work out 9 times 3:

- Calculate 3-1=2 so write 2 in the tens column of the answer
- Calculate 10-3=7 so write 7 in the ones column of the answer

The answer is 27.

These algorithms only work for numbers up to 10. That is probably enough to get you started in primary school. Follow the algorithms without making mistakes and you will get the right answers.

**The underlying pattern**

Computers follow algorithms without caring why or how they work. Humans are curious and if you understand the pattern behind the algorithm you are more likely to remember it. Let’s not leave it as magic, but see why it works.

Let’s look at the 9 times table.

1x9 = 09 2x9 = 18 3x9 = 27 4x9 = 36 5x9 = 45 6x9 = 54 7x9 = 63 8x9 = 72 9x9 = 81 10x9 = 90

Look carefully and you should see the pattern we are exploiting. Every time we move to the next line, the tens column of the answer goes up by 1 and the ones column goes down by 1. Because we start with 1×9 = 09 (putting in the leading 0), the tens column is always 1 less than the number we are multiplying 9 by. As we are adding 1 to the tens column and taking 1 from the units column each time, the two digits always add up to 9 as that is what they started out as in the first line. That means once we know one digit of the answer, subtracting it from 9 gives the other.

This is actually just using a simple mathematical fact:

9 = 10 - 1

Multiplication is just repeated addition, so moving on a line in the 9 times table is just adding 9 which is the same as adding 10 then taking the extra 1 away….

To add 9 to a number we just **add 10** (*increase the 10s column by 1*) **and subtract 1** (*decrease the 1s column by 1*).

That fact incidentally gives an easy algorithm for adding 9 to use any time, any where: rather than counting on 9, just add 10 and take 1 away, both of which are quick and easy.

*To work out 9 plus N (or N plus 9) for any N:*

- Add 10 to N.
- Subtract 1 from the result of step 1 to get the answer

**A general 9 times table algorithm**

Computer scientists (and mathematicians) like to **generalise** things though – meaning make the same algorithm work for as many situations as possible. Perhaps you can see how to adapt our algorithms so far to generalise it to work for any multiply by 9 problem.

How do we adapt the algorithm to work for any multiply by 9 problem? We have to think about what it means to put a digit in the tens column. Actually all we are doing is multiplying the digit by 10, so putting 2 in the tens column just means multiplying 2 by 10 to give its actual value when sitting in the 10s column of 20. Adding this number to the ones column number (eg 7) gives the actual number (eg 20 + 7 = 27). Let’s turn that into an algorithm.

*To work out 9 times N (or N times 9) for any N:*

- Work out N-1 and call this A.
- Multiply A by 10 and call this B
- Subtract A from 9 and call this C
- Add B and C to get the answer

Writing this in a more formal pseudocode:

To work out 9xN for any N: A := N-1 B := 10A C := 9-A Answer := B+C

**Examples**

Let’s try it out with : 3 x 9

A = 3 - 1 = 2, B = 10 x 2 = 20, C = 9 - 2 = 7 Answer = 20 + 7 = 27

Let’s try it out with a bigger multiplication: 12 x 9. Warning! We need to work with negative numbers, here so not for the faint hearted.

A = 12 - 1 = 11, B = 10 x 11 = 110, C = 9 - 11 = -2 Answer = 110 + -2 = 110 - 2 = 108

What about a really big multiplication: 100 x 9

A = 100 - 1 = 99, B = 10 x 99 = 990, C = 9 - 99 = -90 Answer = 990 + -90 = 900

So it seems to work for any number, but can we be sure?

**A variation of the general 9 times table algorithm**

If you prefer to subtract from 10 rather than 9 in the third step (perhaps you find that easier) then here is the pseudocode version of that general algorithm:

To work out 9xN for any N: A := N-1 B := 10A C := 10-N Answer := B+C

Check this new algorithm does work by trying it out on some examples.

**Proving the algorithm works with a bit of algebra**

If you are up for a little algebra we can prove our algorithm *always* works. Thats far better than trying it on a few examples then hoping it works for everything else too. We will prove that the first of our two general algorithms (the subtract from 9 one) always works leaving you to prove the second version does too. To do that we have to show that the calculation the algorithm does is exactly the same as multiplying 9 by N. We start with the equality that results from setting the final answer to be B+C and work backwards substituting in what each variable is set to…

Answer = B + C = 10A + C [Substituting for the value of B] = 10A + (9-A) [Substituting for C] = 10(N-1) + 9-(N-1) [Substituting for A] = 10N - 10 + 9 - N + 1 [Expanding brackets] = 10N - N [Simplifying -10+9+1] = 9N [Simplifying]

We have shown that the calculation this algorithm does is identical to calculating 9N (ie 9 times N). It always works. If we use it for our 9 times table we can get answers with a few simple additions, subtractions and multiplying by 10.

Note we can only use simple substitutions from the algorithm fairly freely like this because we don’t change any variable once set in the above algorithm. If we assigned to the same value twice we’d need to be more careful with our substitutions. Here though we can substitute left hand sides of assignments in for the variable on the right any time it appears in the algebra.

*Becoming an expert at mental maths is just a matter of knowing the tricks and that just means learning a bunch of cunning algorithms, and ideally proving they do always work.*

**Further Reading:** Rob Eastaway and Mike Askew (2010/2014) Maths for Mums and Dads, Square Peg Random House.

More on Computer Science and Maths