# Tricks for computing things in your head

There are quite a lot of tricks/shortcuts enabling doing calculations efficiently in your head. (One of them that came to me today is the "squaring a number ending with a 5" trick I wrote about in this answer). In a comment, user John Golden generously shared a few other tricks like that. These are quite useful, especially in high school, e.g. as a way of showing students stuff they find interesting, and also as a way of promoting numeracy (in a sense of being able to compute or at least estimate things without a calculator or a similar device).

I though that asking for more such tricks - and hence gathering a few of them here - might be useful for MESE users. (I hope the question isn't considered "too broad", even though it does not have a definite answer - on TeX.SE such questions are quite common and can be both interesting and useful. It might be a good idea, though, to convert it to CW.)

• The trick you refer to can be extended a bit. Just as well as you can mentally calculate $65^2=4225$ with the rules that $6\cdot7=42$ and $5^2=25$ you can also do products like $63\cdot67=4221$ as $3\cdot7=21$. Or $41\cdot49=2009$ because $4\cdot5=20$ and $1\cdot9=9=09$. As long as the two double digit factors share the first digit and their last digits add up to ten, the same trick (and proof) works. – Jyrki Lahtonen Apr 15 '14 at 4:10
• If I were trying to speed compute $65^2$ I'd think $(60+5)(60+5) = 3600 + 600 + 25 = 4225\ldots$ – Benjamin Dickman Apr 15 '14 at 4:13
• If you want to multiply two (relatively close) numbers, using difference of squares can be pretty pleasant: $(x+y)(x-y)=x^2-y^2$. – user37 Apr 15 '14 at 4:54
• @BenjaminDickman If I was doing $65^2$ I would do $65*50=\frac12 (6500)=3250$, $65*10=650$ and $65*5=\frac12 (650)=325$ so I get $65^2=(3250+650)+325=3900+325=4225$. It's a fierce personal thing. – JP McCarthy Apr 15 '14 at 12:13
• @Benjamin: That is a slower way than the one given in the link. Often we don't have anything better than the binomial theorem/distributive law, but this trick (with its admittedly limited scope) is something else. My dear old Dad taught it to me a few decades ago :-) – Jyrki Lahtonen Apr 16 '14 at 5:23

I never divide or multiply by 5. I'll double and divide by 2 or divide by 10 and double.

In a similar manner, I was in China last summer and found a quicker way to calculate the temperature in Fahrenheit when given the Celsius temperature: (1) Double the temperature in Celsius, (2) subtract off 10% (something that is easy to calculate), (3) add 32.

• +1 yup. 2X minus 10% is easy. Multiplying by 1.8, not so much. It's a nice thing to discover. – JoeTaxpayer Apr 16 '14 at 0:28

Some tricks I've seen:

## Tricks with notable products

$(a + b)^2 = a^2 + 2ab + b^2$

This formula can be used to compute squares. Say that we want to compute $46^2$. We use $46^2 = (40+6)^2 = 40^2+2\cdot40\cdot6 +6^2 = 1600 + 480 + 36 = 2116$. You can also use this method for negative $b$: $197^2 = (200 - 3)^2 = 200^2 - 2\cdot200\cdot3 + 3^2 = 40000 - 1200 + 9 = 38809$

The last subtraction can be kind of tricky: remember to do it right to left, and take out the common multiples of 10: $40000 - 1200 = 100(400-12) = 100(398-10) = 100(388) = 38800$ The hardest thing here is to keep track of the amount of zeroes, this takes some practice!

Also note that if we're computing $(a+b)^2$ and a is a multiple of $10^k$ and $b$ is a single digit-number, we already know the last $k$ digits of the answer: they are $b^2$, then the rest (going to the right) are zeroes. We can use this even if a is only a multiple of 10: the last digit of $(10 * a + b)^2$ (where $a$ and $b$ consist of a single digit) is $b$. So we can write (or maybe only make a mental note that we have the final digit) that down and worry about the more significant digits.

Also useful for things like $46\cdot47 = 46^2 + 46 = 2116 + 46 = 2162$. When both numbers are even or both numbers are uneven, you might want to use:

$(a+b)(a-b) = a^2 - b^2$ Say, for example, we want to compute $23 \cdot 27$. We can write this as $(25 - 2)(25 + 2) = 25^2 - 2^2 = (20 + 5)^2 = 20^2 + 2\cdot20\cdot5 + 5^2 - 4 = 400 + 200 + 25 - 4 = 621$.

## Divisibility checks

Already covered by Theodore Norvell. The basic idea is that if you represent numbers in a base $b$, you can easily tell if numbers are divisible by $b - 1$, $b + 1$ or prime factors of $b$, by some modular arithmetic.

## Vedic math

A guy in my class gave a presentation on Vedic math. I don't really remember everything and there probably are a more cool things in the book, but I remember with algorithm for multiplication that you can use to multiplicate numbers in your head. This picture shows a method called lattice or gelosia multiplication and is just a way of writing our good old-fashioned multiplication algorithm (the one we use on paper) in a nice way. Please notice that the picture and the Vedic algorithm are not tied: I added the picture because I think it helps you appreciate and understand the pattern that is used in the algorithm. The gelosia notation shows this in a much nicer way than the traditional notation.

The algorithm the guy explained is essentially the same algorithm as we would use on paper. However, it structures the arithmetic in such a way that we never have remember too many numbers at the same time.

Let's illustrate the method by multiplying $456$ with $128$, as in the picture. We work from left to right: we first compute the least significant digits and work our way up.

We start by multiplying the least significant digits:

$6 \cdot 8 = 48$: the least significant digit is $8$, remember the $4(0)$ for the next round (of course, I don't mean zero times four here but four, or forty, whatevery you prefer: be consistent though, if you include the zero here to make forty, you got do it everywhere). $8 \cdot 5(0) = 40(0)$
$2(0) \cdot 6 = 12(0)$
$4(0) + 40(0) + 12(0) = 56(0)$: our next digit (to the left of the $8$) is $6$: remember the $5(00)$

$8 \cdot 4(00) = 32(00)$
$2(0) \cdot 5(0) = 10(00)$
$1(00) \cdot 6 = 6(00)$
$5(00) + 32(00) + 10(00) + 6(00) = 53(00)$: our next digit is a $3$, remember the $5(000)$

Pfff... starting with 2-digit numbers is a better idea, but I wanted to this longer one to make the structure of the algorithm clear. You can do this much faster if you have practiced, since you don't have to write it all down.

$2(0) \cdot 4(00) = 8(000)$
$1(00) \cdot 5(0) = 5(000)$
$5(000) + 8(000) + 5(000) = 18(000)$: next digit is an $8$, remember the $1(0000)$

$1(00) \cdot 4(00) = 4(0000)$
$1(0000) + 4(0000) = 5(0000)$: the most significant digit is a $5$.

So we have $58368$.

There are multiple ways to solve a quadratic equation in your head. The easiest are quadratic with integer coefficients. If we have $x^2 + ax + c = 0$, try to find $r_{1, 2}$ such that $r_1 + r_2 = -a$ and $r_1r_2 = c$. It is also possible to solve for non-integer solutions this way, but it is usually too hard to actually come up with solutions this way.

Another way is just to try divisors of the constant term. By the rational root theorem (google it, I can't link anymore sigh) all solutions to $x^n + ... + c = 0$ need to be divisors of $c$. If $c$ is a fraction $\frac{p}{q}$, the solutions need to be of the form $\frac{a}{b}$ where $a$ divides $p$ and $b$ divides $q$.

If this all fails, we can still put the abc-formula in a much easier form:

$ux^2 + vx + w = 0$
$x^2 + \frac{v}{u}x + \frac{w}{u} = 0$
$x^2 + \frac{v}{u}x + \frac{w}{u} = 0$
$x^2 - ax - b = 0$

$x^2 = ax + b$ (This is the form that I found easiest to use!)
$(x - \frac{a}{2})^2 = (\frac{a}{2})^2 + b$
$x = \frac{a\pm\sqrt{a^2 + 4b}}{2} = \frac{a}{2} \pm \sqrt{(\frac{a}{2})^2 + b}$

I'm sure there are also a lot of techniques for estimating products and the like, but I'm not really familiar with them.

## Tricks that aren't really usable but still pretty cool

See this excerpt from Feynman's "Surely you're joking, Mr. Feynman!" about how he managed to amaze some of his colleagues, and also this video from Numberphile.

• I noted your last intended link does not exist; could you perhaps add it? I was not sure what you wanted to link to. – quid Oct 24 '15 at 22:12
• @quid Sure, indeed something went wrong with the links there. Fixed now. I personally think Feynman's story is more interesting (and also very likely untrue). – Ruben Oct 24 '15 at 23:36

I think $(a+b)(a-b) = a^2 - b^2$ is the most underutilized trick.

A bit of practice and it's easy to see how the square is $b^2$ bigger than the rectangle, and conversely, the rectangle $b^2$ smaller than the square. So 45 squared is (40*50)+25 or 2025. And any multiplying where you can latch on to an easy head math where the true numbers are +/- the difference to the easy result, makes for some fast calculations. And 39*41 is just 1600-1=1599.

On a side note, I've observed that schools have become complacent with calculator use, and this effort (the head math trick) isn't promoted. In my time tutoring student at my High School job, I walk a fine line, encouraging them not to use the calculator for what they can do in their head, but not applying too much pressure. On the other hand, I'll sometimes blurt out a result, showing them that head math is far faster than the time it takes on a calculator. Those bits of time add up when taking our state's standardized tests or the SATs (US based college entrance exam), and in my opinion, that time is going to impact the score.

Yet, there's not going to be any conclusive way to prove such an assertion, as those with head math skills are the kids who are likely to perform better anyway, so no way to produce a study that will satisfy the objective observer.

• +1 for the $(a+b)(a-b)=a^2-b^2$ trick being one of the best. There's a great anecdote of Carl Pomerance (the inventor of the quadratic sieve factoring algorithm!) as a kid being unable to determine in the allotted time how to factor 8051. – ncr May 29 '14 at 22:25

I devised a trick in 8th grade for converting repeating decimals to fractions. They were teaching a very long drawn-out process. My trick basically does the same thing but for some reason they wouldn't let me use it on the test!

Example: $0.36298298298\overline{298} \ldots$ (0.36298 with the 298 repeating).

Explanation:

1) take the complete part of the decimal before the first repetition occurs ($36298$)

2) subtract the non-repeating part ($36$)

3) the denominator will have as many $9$s as there are repeating digits, followed by as many $0$s as there are non-repeating digits ($99900$)

Solution = $(36298 - 36) / (99900) = 36363/99900$.

Done!

To tell if a number is divisible by

• 2, ask whether the last digit even.
• 3, if there is one digit, ask whether it is 0, 3, 6, or 9, otherwise add the digits and ask whether the sum is divisible by 3.
• 4, if the second last digit is even, ask whether the last digit is 0, 4, or 8, otherwise ask whether it the last digit is 2, 6.
• 5, ask whether the last digit is 0 or 5.
• 6, ask whether it is divisible by both 2 and 3.
• 7, chop off the last digit and subtract twice that digit from the remaining number, then ask whether that number is divisible by 7. E.g. 203 --> 20-2*3 --> 14. (You can also add 5 times the last digit. E.g. 98 --> 9 + 5*8 --> 49.)
• 8, if the third last digit is even, ask whether the last two digits are divisible by 8, otherwise ask whether the last two digits are divisible by 4, but not 8.
• 9, add the digits and ask whether the sum is divisible by 9.
• 11, if the number is less than 100, ask whether the two digits are the same, otherwise add the digits in groups of two (e.g. abcdef -> ab + cd + ef) and ask whether the result is divisible by 11.
• and so on.

Because of an exercise we ran every year, I accidentally memorised $\log_{10}2=0.301$, and I could find many logarithms quickly in my head using the log laws. One holiday I decided to take it a little further:

If you memorise the base 10 logarithms of 2, 3 and 7, you can quickly deduce the logs of all the other digits in your head and amaze people with calculators by working out logs to three decimal places of arbitrarily large or small numbers with one significant figure. I'll use log to mean $\log_{10}$ throughout:

Memorised:

• log 2 = 0.301
• log 3 = 0.477
• log 7 = 0.845

Examples you can do in your head - students are entertained by the straining looks on your face and a correct answer with three decimal places:

• log 50 000 = log 100 000 - log 2 = 5 - 0.301 = 4.699
• log 80 000 000 000 = 3 log 2 + log 10 000 000 000 = 0.903 + 10 = 10.903
• log 0.00006 = log 2 + log 3 + log 0.00001 = 0.301 + 0.477 - 5 = 0.777 - 5 = -4.223

You can say "I can only do one significant figure" and they'll accept it, but the bigger and more apparently random the number thus feels, the more amazed they are that you get it right, even though the number of zeros is the trivial bit of the calculation.

I do this as the introduction to my first lesson on logarithms. Some day I'll memorise some logs of larger primes and go to 2s.f..

• – Joel Reyes Noche Jun 6 '14 at 2:36
• Cool! I love the part "I accidentally memorized". ;) – mbork Jun 13 '14 at 9:41
• Error above: $\log 80,000,000,000 = 3 \log 2 + \log 10,000,000,000 = 0.903 + 10 = 10.903$. (It's 160 billion that would give 4 log 2 + log 10^10 = 1.203 + 10 = 11.203.) – Daniel R. Collins Oct 18 '15 at 16:50
• @Daniel hehe - my ability to distinguish between the numbers 3 and 4 clearly let me down! Thanks for the heads up. Edited. – AndrewC Oct 18 '15 at 19:41

This book of Art Benjamin is fantastic. There is a new version of it, but I cannot remember the title.

I should mention that although the book contains many specific "tricks for calculation" as requested by the OP, I think the value of the book is to give a taste for mental constructions for calculation that feel an awful lot like what mathematicians do when working. Benjamin gives insight into how to think about mental calculation and how to use one's working memory (incorporating auditory reinforcements) to carry out computations. The book gives the reader an appreciation for the aesthetic of mental calculation that I haven't found in other books on the topic.

The squares of the first couple of numbers using only the digit one show a nice pattern and are thus easy to remember. They are collected in the list below.

\begin{align} 11\cdot11&=121 \\ 111\cdot111&=12321 \\ 1111\cdot1111&=1234321 \\ 11111\cdot11111&=123454321 \\ 111111\cdot111111&=12345654321 \\ 1111111\cdot1111111&=1234567654321 \\ 11111111\cdot11111111&=123456787654321 \\ 111111111\cdot111111111&=12345678987654321 \end{align}

• This is an example of Pascal's Triangle. – Jasper Sep 12 '17 at 4:01

I agree that the "this is the way this <cool trick> works" can be very motivating, but I see it much more important to learn to do (and use!) what Jon Bentley in his "Programming Pearls" calls "back of the envelope computations" (or even just getting rough estimates, so you aren't embarrased when the finance minister says that "well, 10% of 10% is ... something like... uh, 0.1%").

# Quick "multiplication"

Ask your students to call out digits until you have the entire width of the board filled. Then write $\times\,5$ on the next line. Proceed to right the full answer out from left to right.

With the usual algorithm for multiplying by hand where the answer is produced right to left, it looks like you've already computed the product when you start writing the answer. But if you use division, then you start writing the answer left to right, so the trick is to take advantage of the fact that multiplying by five is the same as multiplying by 10 and then dividing by two.

# (Another) Feynman Method

In his memoris, Richard Feynman actually means a few tricks he saw performed during his time at Los Alamos. It's interesting because the tricks are of a similar form to "multiplication" by five or other tricks involving binomial expansion:

1. some easy transformation into parts that are easier to work with (multiplying by 10, decomposition into some sum of easy numbers)
2. new easier operations (sometimes the operation changes completely, e.g. the example above, sometimes it doesn't, e.g. certain methods of squaring numbers near a certain other number)
3. transformation to the original form (possibly an identity transformation, as in my example)

A discussion of such tricks would actually be a really nice way to lead into ideas like homo- and isomorphy. Logarithms are a classic example of isomorphisms, but are rather difficult to compute by hand. If you have a handy table or mechanical device, i.e, slide rule, then an expensive transformation becomes an easy one, and the computational step also becomes an easy one -- addition instead of multiplication. It's easy enough to make a simple slide rule in the classroom, depending on the age of your audience, and it really brings together a lot of important concepts.

Squaring natural numbers around 50

Let n be an integer "around 50" (which can be anywhere from 30 to 70).

If we write $n$ as $n = 50+m$ then $n^2= 2500+100m+m^2$. So just multiply $m$ by 100, square $m$ (most people know the squares of the natural numbers up to 20), add the two and then add the result to 2500.

To illustrate, let $n = 62$, then $m=12$ and $100m=1200$ and $m^2=12^2=144$, so $100m+m^2=1344$ and now just add 2500 to get your final answer 3844!

• You could similarly use $62^2 = (60+2)(60+2) = 3600 + 240 + 4 = 3844$; I mentioned such a method for $65^2$ in an earlier comment. – Benjamin Dickman Oct 27 '15 at 3:35

Multiplying whole numbers times $25$ is counting quarters. Many American students find this easy.

Getting a better that whole number approximation of square roots is possible using $$\left( a+\frac{1}{2}\right)^2 = a(a+1)+\frac{1}{4}$$

or

$$\left( a+\frac{1}{2}\right)^2 = a^2+a+\frac{1}{4}$$

We can quickly see that $\sqrt{72}$ is between $8$ and $9$, but can we do better?

$8.5^2 = 8\cdot9+0.25 = 72.25$. So $8.5$ is a pretty good approximation for $\sqrt{72}$.

It's not a terribly useful trick, but it is a nice use of the algebra behind it. This is essentially the same trick as that cited by the OP on squaring numbers ending in $5$.

• Could you expand on what you mean by the square root approximation trick? – Chris Cunningham Sep 3 '17 at 14:52
• @ChrisCunningham I don't know if you'll get nitofied, but I've added an example. – Jim H Sep 3 '17 at 15:52
• Ah, so $\sqrt{30}$ is kind of like $5.5$, but $5.5^2 = 30.25$. So we actually know $\sqrt{30} < 5.5$. Neat. Thanks! – Chris Cunningham Sep 4 '17 at 7:48
• This is the same trick as the one that the OP wrote for squaring numbers ending in 5. But here there is a decimal. – Jim H Sep 5 '17 at 18:52

This might be of interest to you - http://en.wikipedia.org/wiki/Vedic_Mathematics_(book) Vedic Mathematics is a book written by the high-ranking Hindu cleric Bharati Krishna Tirthaji and first published in 1965. It contains a list of mental calculation techniques claimed to be based on the Vedas. The mental calculation system mentioned in the book is also known by the same name or as "Vedic Maths".

Source: Vedic Mathematics (book) on Wikipedia

Let me give you some insight how I calculate things by heart:

First we start with the simple formula: $a^2-b^2=(a-b)*(a+b)$

This can be used for two things:

1. perform a multiplication
2. calculate a square

1) Perform a multiplication is the easy one :
In order to multiplicate two numbers, calculate their average and the difference to that average, and substract their squares, as you can see here:

$17*23$

the average is $20$, the difference to the average is $20-17=23-20=3$
So:
$17*20 = (20-3)*(20+3) = 20^2-3^2 = 400-9 = 391$

2) calculate a square, based on :
$a^2-b^2 = (a-b)*(a+b) => a^2 = (a-b)*(a+b) + b^2$

So, how to calculate a square of a number, close to 50,100,200, ...?
Just rely on the distance to that number, as you can see here: $56^2$
56 is close to 50, the difference is 6, so:
$56^2 = (56-6)*(56+6) + 6^2$
$= 50*62+36$
$= 3100+36$
$= 3136$

Next one: how to go from one square to the next one?

• $(a+b)^2=a^2+2*a*b+b^2$
• $(a-b)^2=a^2-2*a*b+b^2$

Let's do this for b=1 and b=2, this gives:

• $(a+1)^2=a^2+2*a+1$
• $(a-1)^2=a^2-2*a+1$
• $(a+2)^2=a^2+4*(a+1)$
• $(a-2)^2=a^2-4*(a-1)$ or $a^2-4*a+4$

How much are now the squares of 21, 29, 42 and 58?

• $21^2=20^2+2*20+1=400+40+1=441$
• $29^2=30^2-2*30+1=900-60+1=841$
• $42^2=40^2+4*(40+1)=1600+164=1764$
• $58^2=60^2-4*60+4=3600-240+4=3360+4=3364$ (subtracting by 4*59 might prove difficult by heart)

Combine this with the square of a number, ending by 5:

$57^2=55^2+4*56=3025+224=3249$

(or if you prefer the method in the first point)

$57^2=(57-7)*(57+7)+7^2=50*64+49=3249$

Next one: how do we divide by numbers, close to natural numbers? (this one has been very handy while converting currencies, before the Euro was introduced)
Imagine the time of the Belgian and the French currency, both were called "fran(c)(k)", and at the end their rate was 5.7. How to divide by 5.7? It comes down to:

$1/5.7 = 1/(6-0.3)$
$= 1/6*(1/(1-1/20))$
$= 1/6*(1+(1/20)+(1/20)^2+(1/20)^3+...)$

can be simplified by:

$1/6*(1+1/20+...)$

So, let's do this:

$600/5.7$

First divide by $6$ => first result = $100$ Divide this by $20$ => $5$,
and add this to the first result => $result = 105$
Divide the $5$ again by $20$ ($0.25$),
and add this to the result => $result = 105.25$
... (you can go on as far as you want, but one or two steps is impressive enough)

And indeed :

$600/5.7 = 105.263...$

Last one:
how to take a square root of a number? (this one is based on $(a+b)^2=a^2+2*a*b+b^2$) Let's do this for, e.g. 328. You need to know the first 20-30 squares by heart, and so you know that this is close to $324=18^2$, hence:
$(18+a)^2=328$, hence:
$324+36*a+a^2=328$, now let go of $a^2$ (it's very small with regards to the other numbers): 36*a is very near to 328-324, or $a=4/36=1/9$, so, next approximation: $sqrt(328)$ is near to $18.11...$ (indeed, it's 18.11077...)

(Sorry for the bad formatting, I'll deal with this later)

To multiply two numbers from $11 - 19$, written in base ten as $1a$ and $1b$, we can use,

$(10 + a)(10 + b) = 100 + (a + b)10 + ab$

It could be remembered as 'One add multiply'. For example, $12 \times 13 = 156$ from $100 + 50 + 6$

When we go higher than the products $12 \times 14$ or $13^2$ care is needed in carrying over,

$13 \times 15 =100 + 80 + 15 = 195$

$17^2 = 100 + 140 + 49 = 289$

Perhaps this is the trick mentioned in the Notices of the AMS article honoring Friedrich Hirzebruch,

where his daughter Ulrike writes,

' he often surprised us with beautiful simple problems, for example, with the trick of how to quickly multiply two numbers between 10 and 20 (he had learned this trick from his father, a math teacher)'

It's not really mental math, but it is more useful that one might expect. And it encourages students to see factoring and grouping possibilities.

Evaluate $P(x) = x^3-7x^2+6x-8$ at $x = 3$.

$$P(3) = (3)^3-7(3)^2+6(3)-8$$

$$= 3(3^2)-7(3^2)+2(3^2)-8$$

$$= (3-7+2)(9)-8$$

$$= -2(9)-8 = -18-8=-26$$

It comes up more often than one might expect in textbook exercises.

I would use it for $P(5)$

$$P(5) = (5)^3-7(5)^2+6(5)-8$$

$$= 25(5)-35(5)+6(5)-8$$

$$= (-10+6)(5)-8$$

$$= -20-8 = -28$$