## Chapter 4. Math

*Numeracy* (the ability to use numbers) is as important as literacy. And while people vary
in mathematical aptitude, almost everyone can improve their math skills,
because numbers are happy to repay the effort of making their
acquaintance.

Because so many people in our culture have trouble with math, improving your math skills will not only help you directly, but can also help you look good and give you an edge at work or school. In keeping with the “mental arts” approach outlined in the Preface, most of the hacks in this chapter involve mental math: math you can do in your head.

## Put Down That Calculator

**You don’t need a calculator to do simple
math! Learn a few tricks, and with a little practice, you’ll be
surprised how much arithmetic you can do in your head.**

Most people need a calculator to do even simple arithmetic. There’s nothing wrong with that, but if a calculator isn’t available, it can become a problem. And even if you don’t count the time to find the calculator, mental arithmetic can actually be faster than a calculator, too.

### In Action

Entire books have been written on mental arithmetic, so we’re not going to cover everything in this hack. This hack covers some typical techniques useful in their own right, and some of the other hacks in this chapter are also useful in doing mental mathematics. If you find this hack interesting and useful, you can check out one of the many books on the subject, some of which are listed at the end of this hack.

You should start at a level that’s not frustrating for you. If
you reach for a calculator to multiply 8 × 7, start by learning the
multiplication tables. Use paper and pencil at first,
and *check your work*.

#### Rearrange

Suppose you need to add the following numbers:

```
9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 +
1
``` |

You *could* add 9 + 8 to get 17, and then
add 7 to that to get 24, and so on. But it’s much easier to
rearrange the addition:

```
9 + 1 + 8 + 2 + 7 + 3 + 6 + 4 +
5
``` |

Each of the first pairs of numbers adds up to 10. So, we have the following easy addition:

```
10 + 10 + 10 + 10 +
5
``` |

which is 45.

In addition to rearranging to find 10s (or 20s), rearranging numbers so that they’re in descending order tends to help. For instance, suppose you’re adding the following numbers:

1100000 270000 3300000 + 30000 ________

It’s probably easier to rearrange that as follows:

3300000 1100000 270000 + 30000 ________

It’s easier because you don’t need to keep track of as many
nonzero digits while adding 3,300,000 and 1,100,000. Adding 270,000
and 30,000 will also help, so you’re left with 4,400,000 +
300,000—an easy sum that totals to
4,700,000.^{1}

#### Put down that burden

When you learned to do paper-and-pencil multiplication in school, you probably learned to work from right to left, carrying as you went:

_{}_{1}_{2}841 x 74 _____ 3364 5887 _____ 62234

Notice that you had to carry twice, once in multiplying the 4 in 74 by the 4 in 841, and once in multiplying the 7 by that 4. If you try to do this mentally, you’ll have to keep track of multiple numbers between steps. For instance, when multiplying the 7 by the 8, you need to remember the 3,364 from the first multiplication, the 87 you’ve already figured out, and the carried 2.

Instead of working right to left, let’s work left to right, just multiplying one of the six pairs of digits at a time. We’re not doing this just to be different; rather, we want to limit the amount of information we need to keep track of.

Before we attempt our previous example, let’s do a simpler problem. Multiplying a two-digit number by another two-digit number turns out to be particularly nice. Suppose we need to multiply 42 × 29. We multiply each pair of numbers (keeping track of the powers of 10), starting at the left, and keep a running total:

The individual calculations look like this:

`40 x 20 = 800` |

`40 x 9 = 360` , and
`800 + 360 = 1,160` |

`2 x 20 = 40` , and
`1,160 + 40 = 1,200` |

`2 x 9 = 18` , and
`1,200 + 18 = 1,218` |

Notice that we have to remember only one number between steps; this remains true even for larger problems. Of course, there’s nothing wrong with writing down that number if paper and pencil are handy, and you’ll probably find this method is still easier and less error prone that the usual method.

### Tip

Because you need the number for only a short time, the mnemonics from Chapter 1 probably aren’t necessary here.

Moving from higher numbers to lower ones tends to work better because it’s easier to add a small number to a large one. As a bonus, if you need only an estimate, you can stop after doing the first few multiplications.

Now, back to our initial example. It contains pairs of digits:

The calculations look like this:

```
800 x 70 =
56,000
``` |

`800 x 4 = 3,200` , and
```
56,000 + 3,200 =
59,200
``` |

`40 x 70 = 2,800` , and
```
59,200 + 2,800 =
62,000
``` |

`40 x 4 = 160` , and
`62,000 + 160 = 62,160` |

`1 x 70 = 70` , and
`62,160 + 70 = 62,230` |

`1 x 4 = 4` , and `62,230 + 4 = 62,234` |

Of course, this is the same answer that we got before; doing a
problem two ways is a good way to check
it.^{2}

### Tip

“Calculate Mental Checksums” [Hack #38] and “Estimate Orders of Magnitude” [Hack #41] discuss other ways of checking your work.

#### Look for friendly numbers

Which addition problem would you rather do: `79`

`+`

`87`

or `80`

`+`

`86`

? Probably the second; it’s
easier because the 80, ending in 0, is a friendly number [Hack #36]. For addition,
numbers ending in 0 are friendly because adding the
corresponding place is trivial (adding 0 to a number doesn’t change
it). Thus, we can mentally add the tens place (`8`

`+`

`8`

`=`

`16`

)
and then just append the 6 for the ones place to get the answer,
166.^{3}

The trick for more difficult addition problems is to change
the problem without changing the answer so that we have friendly
numbers. For instance, if we had `79`

`+`

`87`

, we’d notice that 79 is near
the friendly number 80. To turn 79 into 80, we have to add 1, so to
keep the answer the same, we need to subtract 1 somewhere. Let’s
subtract 1 from the other number, 87, to get 86 and do `80`

`+`

`86`

`=`

`166`

,
as in the previous example.

### Tip

Alternatively, you can add `80`

`+`

`87`

`=`

`167`

, and subtract the 1 from the
result.

The same principle works with
multiplication.^{4} Suppose I ask you to
compute `300`

`×`

```
```

`70`

in your head. Multiplying
`3`

`×`

```
```

`7`

`=`

`21`

and then adding the three 0s, you easily get 21,000. Again, the 0s
at the end make the multiplication easy.

If we need to multiply `302×`

`69`

, we can think as
follows:

```
302 x 69 = (300 + 2) x (70 -
1)
``` |

Now we can do the same cross-multiplication we did before, but with bigger chunks:

```
300 x 70 =
21,000
``` |

`300 x -1 = -300` and
`21,000 - 300 = 20,700` |

`2 x 70 = 140` and
`20,700 + 140 = 20,840` |

`2 x -1 = -2` and
`20,840 - 2 = 20,838` |

Numbers that end in 0 are the friendliest, but factors
of 100 [Hack #36] are
pretty friendly, too. For instance, if you think about the factors
of 100, you’ll find that 25 is a friendly number, and 75 is at least
the friend of a friend. Then, the example we used earlier, `841`

`×`

` `

`74`

, looks like this:

```
841 x 74 = 841 x (75 - 1) = 841 x
75 - 841
``` |

Remember the minus 841, and let’s do `841 x 75`

:

841 x 75 = 841 x 3 x 25 = 2523 x 25 = (2524 - 1) x 25 = 2524 x 25 - 25 = 2524 x 100 / 4 - 25 = 252400 / 4 - 25 = 63100 - 25 = 63075

Finally, subtract the leftover 841, part by part:

```
63,075 - 800 =
62,275
``` |

```
62,275 - 40 =
62,235
``` |

```
62,235 - 1 =
62,234
``` |

which is a third confirmation of the result!

### How It Works

All of these tricks rely on basic properties of integers. For instance, the first multiplication example we gave was 841 × 74. We figured that out by using:

841 x 74 = (800 + 40 + 1) x (70 + 4) = 800 x (70 + 4) + 40 x (70 + 4) + 1 x (70 + 4) = 800 x 70 + 800 x 4 + 40 x 70 + 40 x 4 + 1 x 70 + 1 x 4

The first line uses the definition of the decimal number system [Hack #40], and the remaining lines are repeated applications of the distributive property.

### In Real Life

Suppose you’re playing a card game [Hack #67] with a 52-card deck. Your final score is based on your final cards, and each number card is worth its number (so the 4 of hearts is worth 4 points), with an ace worth 1 point and each face card worth 10 points. Your hand is shown in Table 4-1.

The rearranging method works especially well because we have actual cards to rearrange.

Put the 10 and queen aside: they’re worth 20 points. Then, arrange cards in the following groups (Figure 4-1):

Ace of hearts, 2 of spades, 7 of spades = 10 points

8 of hearts, 2 of diamonds = 10 points

8 of diamonds, 2 of clubs = 10 points

There are 50 points so far; we just need to add the remaining cards, which are the ace of clubs and the 3 of diamonds, for 4 more points. Your total score is 54 points, and you’ve probably figured this out so much faster than anyone else that you can double-check the rules to make sure the three 2s don’t get you some kind of bonus.

### End Notes

Sticker, Henry. 1955.

*How to Calculate Rapidly*. Dover.Julius, Edward H. 1996.

*More Rapid Math: Tricks and Tips*. Wiley.Kelly, Gerard W. 1984.

*Short-Cut Math*, Chapter 2. Dover.Julius, Edward H. 1992.

*Rapid Math Tricks and Tips*. Wiley.

### See Also

Gardner, Martin. 1989.

*Mathematical Carnival*. Mathematical Association of America. Chapters 6 and 7 discuss calculating prodigies and some of the tricks they used.Doerfler, Ronald W. 1993.

*Dead Reckoning: Calculating Without Instruments*. Gulf Publishing Company. This book is a bit more advanced. In addition to the basic operations, it covers extracting roots, and even higher mathematical functions, such as logarithms and trigonometric functions.

Mark Purtill

## Make Friends with Numbers

**With a little experience, you can learn to
recognize many individual numbers by their special properties. Some of
these properties can help you with mental arithmetic and
memory.**

Just like a face in a crowd, a number such as 1,729 probably doesn’t mean much to you. But 1,000,000 looks like a friendly face. With some effort, more numbers can look like friends. Here’s how to get started making their acquaintance.

### In Action

Let’s start with some numbers that you’re probably already friendly with—10 and its powers: 100, 1,000, and so forth. Because we use a decimal number system [Hack #40], powers of 10 end in zeros. Companies are aware of that and try to get phone numbers that are multiples of a power of 10, because those numbers are easy to remember. For instance, the publisher of this book, O’Reilly Media, has a local phone number of (707) 827-7000, which is a multiple of 1,000. Multiplying by a power of 10 is easy; you just have to append zeros:

314 × 1000 = 314000

Similarly, dividing by a power of 10 just removes zeros (or moves the decimal point to the left if there aren’t enough zeros):

2030 / 100 = 20.3

If we look at the factors of 10, which are 2 and 5, we
can come up with other useful rules. (Factors of 10 are also called
*aliquot parts*.) For instance, to
multiply a number by 5, first multiply by 10 and then take half the
result. This is based on the notion that, for multiplication and division, 2 is a friendlier number than 5. For instance,
386 × 5 = (386 × 10) / 2 = 3,860 / 2 = 1,930.

This idea can be extended to factors of powers of 10. For instance, 100 = 4 × 25, so to divide by 25, double the number twice (which is the same as multiplying it by 4) and divide by 100:

217 / 25 = (4 × 217) / 100 = 868 / 100 = 8.68

If you’re estimating, near factors can also be useful: 33 × 3 = 99, which is almost 100, and 17 × 6 = 102, which is just a little more than 100.

### How It Works

Unlike some of the hacks in this chapter, this one can’t give you a straightforward recipe that’s guaranteed to make every integer you encounter unique. After all, the hack involves finding something unusual about the number. If every number you met exhibited the same unusual feature, it obviously wouldn’t be unusual. Becoming more familiar with the number system is a gradual process. However, I can give you a few tips:

- Start with smallish numbers
Although we’ll give an example of hacking a seven-digit phone number later, it might be easier to hack the three-digit and four-digit parts separately, or even split the number into the three-digit part and two two-digit parts.

- Try factoring
We already talked about factors of powers of 10 (such as 4 and 25). Factoring in other ways can be useful in mental (or paper-and-pencil) arithmetic. For instance, if you have to multiply 193 by 56, it might be easier to factor 56 into 8 × 7, and then multiply each factor separately:

193 x 56 = 193 x 8 x 7 = 193 x 2

^{3}x 7 = 386 x 2^{2}x 7 = 772 x 2 x 7 = 1544 x 7 = 10808In this example, we multiplied by 8 by doubling three times.

- Look for patterns and near patterns
I once had a prescription number that was 66123465. This was easy to remember because of two patterns: all my prescription numbers started with 66 and the rest of the number was almost 123456. Remembering the one difference from the pattern was easier than remembering the whole number.

- Associate numbers with uses
If you’re a sports fan and you know your favorite player wore number 80, remembering other 80s might be easier by associating them with that player. (This is a variant of the mnemonic techniques presented in Chapter 1.)

- Find friends of friends
In arithmetic, this mostly means numbers close to other numbers. For instance, 4 × 24 is easy to compute as 4 × (25 – 1) = 100 – 4 = 96.

In terms of mnemonics, any way you can connect numbers is fine.

### In Real Life

We’ve already talked about arithmetic, so we’ll concentrate on mnemonics here. Let’s see what we can do with O’Reilly’s toll-free number—(800) 998-9938—in case you want to order more copies of this book. (What am I saying, “in case”?)

Since many toll-free numbers start with 800, this should not be a problem. Notice that 800 was chosen to be a multiple of 100. Then notice that the 998 almost repeats: not only is the second part 99?8, but the extra digit is a 3, which you can think of as a broken 8.

Depending on your tastes, there are other ways to proceed. For instance, back in college, I remember one time I ran into my friend Ben at the beginning of the school year. He told me his phone number: 436-7062. I didn’t bother writing it down. I was sure I could remember it without writing it down. And, 20 years later, I do remember it, even though Ben moved out of that particular dorm room 19 years ago.

How did I do it? I saw that number not merely as a sequence of seven numerals, in which form it seems rather arbitrary, but as a particular seven-digit number, and looked for its special properties as a number. Let’s try factoring to start, although we’ll use some of the ideas mentioned previously as we go along.

First, checking for divisibility [Hack #37], I saw that 4,367,062 is divisible by 2 (because the last digit is even) and 7 (because +62 – 367 + 4 = –301 and –301 / 7 = –43). I could also see that there were no more small factors. If we divide by the factors I got (that is, 2 and 7) and use techniques similar to those in “Put Down That Calculator” [Hack #35], we obtain the following results:

4367062 / 2 = 2183531 2183531 / 7 = 311933

So, 4,367,062 = 2 × 7 × 311,933.

Now, there’s a pattern to the number 311,933: if you multiply the first three digits by 3, you get the last three digits. A little thought (and a nodding acquaintance with a few other integers) tells us that this means:

311933 = 311 x 1003

Here I got lucky: both of those numbers were already friends (so
our number 311,933 is a friend of those friends). 311 is
prime, and 1,003 is 17 × 59, also both prime. As a mathematician, prime numbers—those numbers
with no factors other than 1 and themselves—are interesting and often
“friendly,” and for various reasons^{1} 17 is
a *very* old friend, so I already knew the
factorization of 1,003.

The complete factorization is:

2 x 7 x 17 x 59 x 311

For me, all of those numbers are friends, and the factorization is nice, with only one of each prime factor. That was enough for me to remember the phone number.

That information might not help you remember the number. The key
is to make friends with numbers in your own way. Everyone will have
different ways of doing this. For instance, mathematicians love to
tell the story of Srinivasa Ramanujan, a great mathematician active in the early
20th century. His friend and colleague, G. H. Hardy, visiting him in the hospital, was making small
talk. Hardy mentioned that the cab that took him to the hospital was
number 1729—to Hardy’s disappointment, because it was such a boring
number. Ramanujan disagreed: 1,729 was quite an interesting number,
being the smallest number that can be written as a sum of two positive
cubes in two different ways.^{2}

Ramanujan was quite correct: 10^{3} +
9^{3} = 1,000 + 729 = 1,729, and
12^{3} + 1^{3} = 1,728
+ 1 = 1,729. It’s straightforward, if a little tedious, to check that
no smaller integer has this property. If I told you the property that
Ramanujan mentioned, you could figure out the number 1,729 with a lot
of tedious, routine computation, but to go in the other direction is
rather remarkable. Even most professional mathematicians would have
trouble doing that, except for the fact that this story is so popular.
J. E. Littlewood, another colleague and frequent collaborator
of Hardy and Ramanujan, put it this way: every positive integer was
one of Ramanujan’s personal friends. A single face in the crowd is
recognizable if you know the person. So it was with numbers for
Ramanujan.

Of course, even if you can’t recognize
*every* face in a crowd, recognizing
*some* faces can still be helpful!

### End Notes

Lefèvre, Vincent. 1998. “17 (Seventeen) and Yellow Pigs.” http://www.vinc17.org/yp17/index.en.html

*.*MathPages.com. “The Dullness of 1729.” http://www.mathpages.com/home/kmath028.htm.

Moses Klein and Mark Purtill

## Test for Divisibility

**It’s often useful to know whether one number
is evenly divisible by another number. Here are some tricks that go
beyond knowing whether a number is odd or even, or divisible by
10.**

Before decimals such as 3.5 were invented, people had to
use numbers with fractional parts instead, such as
3^{1}/^{2}. In many
division problems, they had to reduce fractions with large numbers—for
example, 243 / 405—to their lowest terms—in this case,
^{3}/^{5}. Knowing rules
to determine divisibility by the integers from 1 through 12, or from 1
through 15, was very useful in that precalculator
time.^{1}

If you want to strengthen your mental math powers, knowing the
same rules can be useful to you today. In particular, these rules are
helpful with math tricks that involve factoring numbers, such as simplified mental
multiplication. Sometimes, knowing *that* a number is
evenly divisible by another number goes at least halfway toward knowing
*what* the answer is.

### In Action

The following list gives tests for divisibility by all
integers from 1 to 15. In this context,
*divisible* means *evenly
divisible*—that is, divisible with a remainder of 0.

If the number’s last digit is even (0, 2, 4, 6, or 8), the number is divisible by 2.

*Examples:*22, 136, 54, 778.If the number’s digit sum is 0, 3, or 6 (or 9, which is the same as 0 for this purpose), the number is divisible by 3. (See “Calculate Mental Checksums” [Hack #38] for how to calculate digit sums.)

*Example:*138 (1 + 3 + 8 = 12; 1 + 2 = 3).If the last two digits of the number, taken as a two-digit number, are divisible by 4, so is the number.

*Example:*216 (16 is divisible by 4).If the last digit of a number is 0 or 5, the number is divisible by 5.

*Example:*147,325 (the last digit is 5).If a number is divisible by both 2 and 3, the number is also divisible by 6. (See the tests for 2 and 3.)

*Example:*138 is divisible by 2 because its last digit is 8. It is also divisible by 3 because 1 + 3 + 8 = 12 and 1 + 2 = 3. Therefore, it’s also divisible by 6.See the “Divisibility by 7" sidebar.

If the last three digits of the number, taken as a three-digit number, are divisible by 8, so is the number.

*Example:*2,889,888 (the last three digits, 888, are divisible by 8).If the number’s digit sum is 0 (or 9, which is the same as 0 for this purpose), the number is divisible by 9. (See “Calculate Mental Checksums” [Hack #38] for how to calculate digit sums.)

*Example:*41,805 (4 + 1 + 8 + 0 + 5 = 18; 1 + 8 = 9).If the last digit of a number is 0, the number is divisible by 10.

*Example:*99,310 (the last digit is 0).Casting out elevens [Hack #38] is the easiest way to test for divisibility by 11 in most cases: if the number modulo 11 is 0, the number is divisible by 11.

If a number is divisible by both 3 and 4, the number is also divisible by 12. (See the tests for 3 and 4.)

*Example:*624 is divisible by 3 because 6 + 2 + 4 = 12 and 1 + 2 = 3. It is also divisible by 4 because the last two digits (24) are divisible by 4. It is therefore divisible by 12.If 9 times the last digit of the number, subtracted from the number with its last digit deleted, is divisible by 13, so is the number.

^{2 }*Example:*351 is divisible by 13 because 35 – 9 × 1 = 26. Since 26 is divisible by 13, so is 351.If a number is divisible by both 2 and 7, the number is also divisible by 14. (See the tests for 2 and 7.)

*Example:*65,282,490 is divisible by 2 because it ends in 0. It is also divisible by 7 because it is 7 less than 65,282,497, which we know is divisible by 7 from the example in the “Divisibility by 7" sidebar. Since it is divisible by both 2 and 7, it is divisible by 14.If a number is divisible by both 3 and 5, the number is also divisible by 15. (See the tests for 3 and 5.)

*Example:*3,285 is divisible by 3 because 3 + 2 + 8 + 5 = 18 and 1 + 8 = 9. It is also divisible by 5 because it ends in 5. Therefore, it is divisible by 15.

### In Real Life

Here’s an example of the kind of situation where knowing tests for divisibility will come in handy in real life.

You’re at a dinner for 11 people. The restaurant is closing, and everyone agrees to split the bill evenly to save time, but no one has a pocket calculator or PDA handy.

The bill is $419.15, including gratuity. You round this to $419, and cast out elevens. The result is 1, which means that by subtracting 1 from 419, you’ll reach a number evenly divisible by 11, which is 418. Quick mental division shows you that everyone owes $38 (418 / 11 = 38), and that if random people around the table contribute some pocket change to make up the difference of $1.15, you can pack up and get out of the restaurant quickly.

### End Notes

Gardner, Martin. 1991. “Tests of Divisibility.”

*The Unexpected Hanging and Other Mathematical Diversions*. The University of Chicago Press. An excellent article on divisibility, and a primary source for this hack. Gives the rules for 1 through 12, several additional tests for divisibility by 7, magic tricks involving divisibility, and more, in the wonderful Gardner style.Wikipedia article. “Divisor.” http://en.wikipedia.org/wiki/Divisor. Gives the rules for 13–15, defines some terminology, outlines some basic principles, and specifies a somewhat elaborate rule for determining divisibility of any integer, in any base, by any smaller integer.

## Calculate Mental Checksums

**Computers use checksums to ensure that data
was not corrupted in transmission. Now your brain can use a checksum for
your mental math, with a few easy techniques.**

It’s important to have some way to check your mental math
that doesn’t take as long as solving the problem did originally, and
ideally is much shorter. It’s easy to check your math for the four basic
operations of arithmetic (addition, subtraction, multiplication, and division) by
calculating *digit sums* for the numbers involved.
A digit sum is a special kind of *checksum* or data
integrity check. Checksums are used all over the world of computing,
from credit cards to ISBNs on books, to downloads you make with your web
browser. Now your brain can use them, too.

Finding the digit sum of a number is easy. Just add all the digits of the number
together. If the result is greater than 9, add the digits together
again. Continue to do so until you have a one-digit result. If the
result is 9, reduce it to 0. The result is the digit sum of the original
number.^{1}

For example, the digit sum of 381 is 3:

3 + 8 + 1 = 12 1 + 2 = 3

Similarly, the digit sum of 495 is 0:

4 + 9 + 5 = 18 1 + 8 = 9 (same as 0)

A number’s digit sum is actually that number *modulo
9*—in other words, the remainder when that number is divided
by 9. See “Calculate Any
Weekday” [Hack #43] for a refresher on modulo arithmetic.

This technique is also known as *casting out nines*. Casting out nines
and a similar technique known as *casting out elevens* (discussed in
the following section) are all you need to check your arithmetic
calculations rapidly and to a high degree of accuracy.

### In Action

This section shows how to calculate checksums for the four basic operations: addition, subtraction, multiplication, and division. Only integers are used in the examples, but the techniques will work just as well for real numbers as long as they have the same number of decimal places. For example, if you are multiplying 13.52 by 14.6, think of the latter number as 14.60.

#### Addition

To check your answer after addition:

Find the digit sums for the numbers you are adding.

Add all the digit sums together.

Find the digit sum of the new number, and the digit sum of the answer number.

Compare these two digit sums. If the digit sums match, the answer should be correct.

Here is an example of checking addition successfully:

95 9 + 5 = 14; 1 + 4 = 5 + 42 4 + 2 = 6 + 22 2 + 2 = 4 ... 5 + 6 + 4 = 15; 1 + 5 = 6 159 1 + 5 + 9 = 15; 1 + 5 = 6 : OK

Here is another example of checking addition:

49 4 + 9 = 13; 1 + 3 = 4 + 37 3 + 7 = 10; 1 + 0 = 1 ... 4 + 1 = 5 76 7 + 6 = 13; 1 + 3 = 4 : WRONG (the answer should be 86)

The fact that the digit sum of the numbers being added does not match the digit sum of the result tells you that the result is incorrect.

### Tip

Digit sums are even easier to calculate if you treat the 9s as 0s right away. Thus, instead of 4 + 9 = 13 in the example, just compute 4 + 0 = 4 and obtain your digit sum in one step.

#### Multiplication

To check your answer during multiplication:

Find the digit sums for the numbers you are multiplying.

Multiply them.

Find the digit sum of the new number, and the digit sum of the answer number.

Compare these two digit sums. If the digit sums match, the answer should be correct.

Here is an example of a correct multiplication:

33 3 + 3 = 6 x 27 2 + 7 = 9 = 0 ... 6 x 0 = 0 891 8 + 9 + 1 = 18; 1 + 8 = 9 = 0 : OK

Here is another example of checking multiplication:

76 7 + 6 = 13; 1 + 3 = 4 x 14 1 + 4 = 5 ... 4 x 5 = 20; 2 + 0 = 2 1164 1 + 1 + 6 + 4 = 12; 1 + 2 = 3 : WRONG (the answer should be 1064)

The fact that the digit sum of the product of the digit sums of the numbers being multiplied does not match the digit sum of the result tells you that the result is incorrect.

#### Subtraction

Subtraction is the inverse of addition. Checking a subtraction problem works the same way as checking an addition problem: simply turn the subtraction problem into an addition problem first, as in the following example:

58 26 2 + 6 = 8 - 26 → + 32 3 + 2 = 5 ... 8 + 5 = 13; 1 + 3 = 4 32 58 5 + 8 = 13; 1 + 3 = 4 : OK

#### Division

Just as subtraction is the inverse of addition, so is division the inverse of multiplication. Thus, checking a division problem works the same way as checking a multiplication problem: first turn the division problem into a multiplication problem, as in the following example:

1081 / 23 = 46 23 2 + 3 = 5 x 46 4 + 6 = 10; 1 + 0 = 1 ... 5 x 1 = 5 1081 1 + 0 + 8 + 1 = 10; 1 + 0 = 1 : WRONG (the answer should be 47, not 46)

The fact that the digit sum of the product of the digit sums of the numbers being multiplied does not match the digit sum of the result tells you that the division result of 46 is incorrect.

#### False positives

Sometimes casting out nines will not find an error. For example, sometimes errors in two digits will cancel out, as in the following example:

272 2 + 7 + 2 = 11; 1 + 1 = 2 + 365 3 + 6 + 5 = 14; 1 + 4 = 5 ... 2 + 5 = 7 547 5 + 4 + 7 = 16; 1 + 6 = 7 : OK?

The correct answer is not 547, but 637 (6 + 3 + 7 = 16; 1 + 6 = 7).

Casting out nines will also not find *errors of place* (when the decimal
point is misplaced, or the result is otherwise off by a power of
10). Estimating the order of magnitude [Hack #41] (roughly, finding
the number of digits to the left of the decimal point) will help
catch some errors of place, but casting out elevens is even better.

#### Casting out elevens

Casting out elevens (that is, calculating numbers *modulo 11*) is slightly more
accurate than casting out nines. It will also catch errors that
casting out nines will not, including errors of place,
so it is useful as a cross-check.

To cast out elevens from an integer, simply add all of the digits in the odd places of the number (for example, the ones and hundreds digits, which are in places 1 and 3, counting from the right), then subtract all of the digits in the even places (for example, the tens and thousands digits, in places 2 and 4).

For example, casting out elevens from 5,924 gives the result 4 + 9 – 2 – 5 = 6.

If your result is greater than 11, cast out elevens
from *that* number, and continue doing so until
you have a number that’s less than 11. If the result is less than 0,
add 11 to it until you have a number that is at least 0 and less
than 11. To cast out elevens from a sum, total the result of casting
out elevens for each number you’re adding, and then cast out elevens
from that.

The following example is a cross-check of the sum from the previous section:

272 2 + 2 - 7 = -3; -3 + 11 = 8 + 365 5 + 3 - 6 = 2 ... 8 + 2 = 10 547 7 + 5 - 4 = 8 : WRONG (the answer should be 637)

### How It Works

A rigorous mathematical proof that casting out nines by summing the digits of a number will give you that number’s remainder when divided by 9 is beyond the scope of this book, but it’s fairly intuitive.

First, consider that `0`

`mod`

`9`

is `0`

,
`1`

`mod`

`9`

is
`1`

, `2`

`mod`

`9`

is `2`

, `3`

`mod`

`9`

is `3`

,
and so on. `9`

`mod`

`9`

is
`0`

, `10`

`mod`

`9`

is `1`

, `11`

`mod`

`9`

is `2`

,
and the cycle continues.

Next, consider that `20`

`mod`

`9`

is `2`

,
`30`

`mod`

`9`

is
`3`

, and so on; check and see. You
will also find that `200`

`mod`

`9`

is
`2`

, `2,000`

`mod`

`9`

is `2`

, ```
20,000
mod
```

`9`

is `2`

, and so on. In fact, any integer
multiplied by any power of 10 and then calculated modulo 9 has the same result as the original integer
modulo 9.

Since `(a`

`+`

`b`

`+`

`c)`

`mod`

`9`

is the same as `(a`

`mod`

`9)`

`+`

`(b`

`mod`

`9)`

`+`

`(c`

`mod`

`9)`

,
and since (for example) the number 523 can be written as `500`

`+`

`20`

`+`

`3`

,
simply adding the individual digits of 523 `(5`

`+`

`2`

`+`

`3)`

will
serve the same purpose as calculating the sum of 500 mod 9, 20 mod 9,
and 3 mod 9, to wit, finding 523 modulo
9.^{2}

Figuring out why casting out elevens works is left as an exercise for the mathematically minded mind-performance hacker.

### In Real Life

Mental checksums are most useful when you combine them with other math hacks [Hack #75]. Since checksums using both 9 and 11 are easy to find, checking your work won’t add much time to your mental calculations unless you made a mistake—in which case, better late than wrong.

## Turn Your Hands into an Abacus

**You might have heard stories of how rapid
and accurate calculations with an abacus can be, but did you know that
the abacus might have been based on an ancient technique using only the
human hand, which survives today as the Korean art of
Chisenbop?**

*Chisenbop* is an ancient Korean technique for
calculations with the human hand. The classic text on Chisenbop in
English is *The Complete Book of
Fingermath*.^{1} Unfortunately, it is
expensive, aimed toward children, and takes hundreds of pages to explain
principles that an educated adult can learn in a few minutes. One
important thing that the book can offer you, however, is page after page
of drills. Chisenbop should become a motor skill, not something you have
to think about.

*Fingermath* also uses many full, detailed
drawings of hands in action, which is another reason the book is so
long. Fortunately, the Wikipedia presents a notation that can radically compress
Chisenbop diagrams on the page, as shown in Table 4-2.^{2}

### Tip

I added a couple of symbols to the notation myself for this book
(`^`

and `v`

, which are described in Table 4-2).

You can combine the finger notation across two hands, as shown in the examples in Table 4-3.

This remainder of this hack describes the basic operations of Chisenbop.

### Counting

Here is how to count to 100 or more on your fingers. Keeping all your other fingers off the table, you press your right index finger to the table. This represents the number 1:

Keeping your right index finger on the table, you press your right middle finger on the table. This represents the number 2:

The next two fingers down represent 3 and 4, respectively:

To represent 5, *clear* your other four
fingers on your right hand (lift them off the table) and
simultaneously press your right thumb to the table. Your thumb
represents 5:

For 6, keeping your right thumb on the table, press your right index finger down on the table (5 + 1 = 6):

You can get as high as 9 on your right hand by pressing the next three fingers on your right hand in succession so that all the fingers are pressed:

To count from 10 up through 99, you will need to start using your left hand as well.

Clear all the fingers on your right hand and simultaneously press the index finger of your left hand. This is 10. It’s analogous to how you count 1 on your right hand by pressing your right index finger.

By adding the fingers of your right hand from 1 through 9, you can get as high as 19:

Notation | Meaning |

...o- -o... | 11 |

...o- -oo.. | 12 |

...o- -ooo. | 13 |

...o- -oooo | 14 |

...o- @.... | 15 |

...o- @o... | 16 |

...o- @oo.. | 17 |

...o- @ooo. | 18 |

...o- @oooo | 19 |

Of course, to count to 20, you make another exchange. Clear your right hand and press the middle finger of your left hand:

This is analogous to how you count 2 on your right hand because 20 = 2 × 10.

Counting by tens, the other numbers up through 90 follow logically:

Notation | Meaning |

.ooo- -.... | 30 |

oooo- -.... | 40 |

....@ -.... | 50 |

...o@ -.... | 60 |

..oo@ -.... | 70 |

.ooo@ -.... | 80 |

oooo@ -.... | 90 |

And here’s a full Chisenbop 99:

If you want to count past 99, you need to remember a number in
your head. That number is how many hundreds you need to add to your
hand abacus at the end of your calculation. Fortunately, all that
involves is tacking the *hundreds* number onto the
front of the number shown by your hands. So, if your hands show
this:

and your hundreds number is 3, the number you have counted to is 352, which you can show like this:

Therefore, to break past 99, clear your hands and say to yourself “one hundred.” Both hands will now show zero, to which you will add the hundred in your head by prepending one, and the Hubble horizon is the limit!

### Addition

Addition is simply counting by larger chunks than 1. For example, to add 15 + 23, place your hands in the 15 position:

Now, press two more fingers representing 10 each on the left hand. This means you’re adding 20:

Almost there. Now, press three more fingers on your right hand for the 3 in 23:

So, 15 + 23 = 38. It might have been easier to do it this way:

### Subtraction

Simply put, if addition is counting forward by chunks, subtraction is counting backward by chunks. Instead of pressing your inner fingers down and moving out, you are lifting your outer fingers and moving in. It’s quite simple; it just takes practice.

Here’s how to figure 38 – 23 = 15:

### Multiplication

Multiplication is just repeated addition. For example, 3 × 15 = 45 means 15 + 15 + 15 = 45:

It’s useful to drill in adding by arbitrary chunks, starting
with counting by twos, moving up as high as counting by nines, and
then moving into counting by double digits. You want your Chisenbop to
become an unconscious *motor skill*; otherwise, you
might need to keep intermediate results in your head. For example,
when multiplying by 15, you might need to repeatedly add 10 and then
remember to add 5. Not only is this not the Way of Chisenbop, but it
is also error-prone.

Note that when you multiply, you always need to remember a
second number in your head, in addition to the
*hundreds*—that is, how many times you’ve added the
number by which you’re multiplying. (Don’t read the result off your
fingers until you’re done.) So, in the previous example, when you
first place your fingers on the table in the 15 position, you say,
“One!” When you add a second 15, you say, “Two!” And when you add the
final 15, you say, “Three!” *Now* read the result
off your fingers: presto, 45!

### Division

If multiplication is repeated addition, division is repeated subtraction. You can divide by repeatedly subtracting the divisor until you can’t subtract it anymore. The number of times you could subtract the divisor is the result, and the number left over on your fingers is the remainder. Thus, 15 can be subtracted from 45 three times, leaving all fingers clear (a remainder of zero), showing that 45 / 15 = 3, remainder 0. Likewise, 15 can be subtracted from 46 three times, leaving your index finger pressed, showing that 45 / 15 = 3, remainder 1.

In practice, it’s probably easier to work in the opposite direction. For example, you can divide a number by 7 by counting sevens until you exceed the number you are dividing. The number of sevens in the number you are dividing is one less than the number at which you finished. For example, to divide 81 by 7, count 7 (1), 14 (2), 21 (3), 28 (4), 35 (5), 42 (6), 49 (7), 56 (8), 63 (9), 70 (10), 77 (11), 84 (12)—oops! That’s 12 sevens, which is too many, so there are 11 sevens in 81, with a remainder of 4.

### End Notes

Lieberthal, Edwin M. 1982.

*The Complete Book of Fingermath*. A & W Visual Library.Wikipedia. 2005. “Chisenbop.” http://en.wikipedia.org/wiki/Chisenbop.

### See Also

Harris, Andy. “Chisenbop Tutorial.” http://www.cs.iupui.edu/~aharris/chis/chis.html (this page from Purdue University contains an interactive, animated Chisenbop tutorial and several lessons presented via streaming media).

## Count to a Million on Your Fingers

**You can use binary arithmetic to count to
more than a million on your fingers.**

You probably already know that you can use Chisenbop [Hack
#39] to count to 100 or more and do simple arithmetic on your
fingers. If you switch from the decimal numeral system to binary,
however, you can use your fingers to count to about
2^{20}, which is 1,048,576—more than a
million!^{1}

### The Binary Numeral System

First, let’s review the binary numeral system. (If you don’t need a review, you can skip to the next section.)

The number system we use normally is called the *decimal numeral system* because it
is based on powers of 10. For instance:

4309 = (4 x 1000) + (3 x 100) + (0 x 10) + (9 x 1)

Note that in the decimal system there are 10 digits: 0 to 9. Each position in a decimal number corresponds to a power of 10; for instance, 3 is in the hundreds position in the decimal number 4,309.

The *binary numeral system* is based on
powers of 2, so there are only two digits, 0 and 1.
These are referred to as *bits*, which is short for
*binary digit*. Thus, in binary:

= (1 x 16) + (0 x 8) + (0 x 4) + (1 x 2) + (1 x 1) = 19`10011`

### Tip

In this hack, I’ll highlight binary numbers in bold, so you can tell them apart from ordinary decimal numbers. Without some convention, it would be impossible to tell whether a number like 10011, with only 1s and 0s, is binary or decimal.

Notice that because only 1 and 0 are used, there’s no real
multiplication here: we just add up the positions with
1s in them. In the case of 10011, that’s ```
16 +
2 + 1 = 19
```

.

### In Action

Now we can explain how to count on your fingers in binary. The basic idea is to have a finger designate each position. Let’s start with one hand. For example, suppose that on the right hand, the thumb is the 1 position, the index finger is the 2 position, the middle finger 4, the ring finger 8, and the pinky 16. Each finger can be down (representing 0) or up (representing 1).

Start with all fingers in the down position. Thus, each position has a 0, and this represents the number zero (00000 = 0). You can represent any 5-bit number with one hand. For instance, to represent 10011 (which is 19 in decimal) using the system outlined in the previous section, place your fingers as in Table 4-4 and Figure 4-2.

Finger | Value | Gesture | Bit |

Pinky | 16 | Up | 1 |

Ring | 8 | Down | 0 |

Middle | 4 | Down | 0 |

Index | 2 | Up | 1 |

Thumb | 1 | Up | 1 |

The rule for adding 1 is simple: each time you increment the number, look for the smallest-position finger that is down. Raise it, and lower all fingers in even smaller positions.

For example, starting with 19 as in the previous example, we
would raise the middle finger (the 4 position) and lower the index
finger and thumb (the 2 and 1 positions, which are those smaller than
the 4 position). Keep the pinky and ring fingers in the same position,
as shown in Table 4-5 and Figure 4-3. This represents the
number 10100 (`16`

`+`

`4`

`=`

`20`

).

Finger | Value | Gesture | Bit |

Pinky | 16 | Up | 1 |

Ring | 8 | Down | 0 |

Middle | 4 | Up | 1 |

Index | 2 | Down | 0 |

Thumb | 1 | Down | 0 |

Incrementing again, we would just raise the thumb (since it’s
the smallest-position finger that’s down). Since there are no smaller
positions than the thumb, no fingers are lowered. The number
represented is 10101 (`16`

`+`

`4`

`+`

`1`

`=`

`21`

).

With only one hand, we can represent numbers up to 11111 (31).
To get up to 1,000, we proceed to the other hand: the thumb on the
*left* hand represents the 32 position, the index
finger represents 64, the middle finger 128, the ring finger 256, and
the pinky 512. With this, we can represent numbers up to 1111111111
(1,023). For instance, 1,000 is represented as 1111101000 because
`512`

`+`

`256`

`+`

`128`

`+`

`64`

`+`

`32`

`+`

`8`

`=`

`1,000`

. (See Table 4-6 and Figure 4-4.)

Left hand | Right hand | ||||||

Finger | Value | Gesture | Bit | Finger | Value | Gesture | Bit |

Pinky | 512 | Up | 1 | Pinky | 16 | Down | 0 |

Ring | 256 | Up | 1 | Ring | 8 | Up | 1 |

Middle | 128 | Up | 1 | Middle | 4 | Down | 0 |

Index | 64 | Up | 1 | Index | 2 | Down | 0 |

Thumb | 32 | Up | 1 | Thumb | 1 | Down | 0 |

### Tip

An alternate way of figuring this out is to compute the left hand separately, multiply it by 32, and add the right hand. For example, on your left hand: 11111 = 31; 31 × 32 = 992. Then, compute on your right hand: 01000 = 8. Finally, 992 + 8 = 1,000.

That gets us past 1,000, but we’re out of fingers. So why did we
say you can count to a million this way? The same fingers can
*simultaneously* represent a new,
*independent* set of bits, which will have values
1,024, 2,048, and so on, up to 524,288. For these higher-valued bits,
a finger held straight is off (0), and a curled finger is on
(1).

Now that you’ve added curled fingers to your binary repertoire, the rule for incrementing must be extended. The previous rule of raising the smallest-position lowered finger and lowering all the fingers in smaller positions still applies. Now, however, if and only if all of your fingers are raised (whether curled or straight), and you want to add 1, lower all your fingers, curl the smallest-position straight finger, and straighten any lower-position curled fingers.

Let’s see how we’d represent 1,000,000 with this scheme.
1,000,000 = 11110100001001000000, because 1,000,000 = 2^{19
} `+`

2^{18
} `+`

2^{17
} `+`

2^{16
} `+`

2^{14
} `+`

2^{9
} `+`

2^{6} = 524,288 `+`

262,144 `+`

131,072 `+`

65,536 `+`

16,384 `+`

512 `+`

64.

Splitting this into groups of five (for the five fingers), we must position our fingers as shown in Table 4-7.

Bit | Gesture |

11110 | Left hand curled/straight |

10000 | Right hand curled/straight |

10010 | Left hand up/down |

00000 | Right hand up/down |

Finger by finger, 1,000,000 (**11110100001001000000**) looks like Tables 4-8 and 4-9 and Figure 4-5.

Finger | Value | Gesture | Bit | Value | Gesture | Bit |

Pinky | 524,288 | Curled | 1 | 512 | Up | 1 |

Ring | 262,144 | Curled | 1 | 256 | Down | 0 |

Middle | 131,072 | Curled | 1 | 128 | Down | 0 |

Index | 65,536 | Curled | 1 | 64 | Up | 1 |

Thumb | 32,768 | Straight | 0 | 32 | Down | 0 |

### In Real Life

Instead of holding one number on both hands, you can store one number on each hand. This might be useful in keeping score in a two-player game, for instance.

Additional bits are available elsewhere on your body: for instance, your wrists.

Once you get familiar with binary numbers, you can experiment more with addition and even try subtraction (these might make being able to represent numbers up through 1,000,000 more useful).

### How It Works

Incrementing is just adding 1, and binary arithmetic works the same as decimal arithmetic (except it’s easier because there are only two bits). For instance, the computation we did as the first example (19 + 1 = 20, in decimal) works like this:

_{1}_{1}`10011`

`+ 1 _____`

`10100`

Since the lowest position is **1**,
adding **1** gives **2**, which is **10**
in binary. So, we put down **0** and
carry the **1**. (This corresponds to
lowering the thumb.) Adding the carry to the **1** in the 2 position again gives **10**, so we again have **0** with a carried **1**. (This corresponds to lowering the index
finger.) In the 4 position, we have a **0**, and **0 **+
**1** = **1**. (This corresponds to raising the middle
finger.) The other digits remain the same, just as the corresponding
fingers do.

The next increment (20 + 1 = 21) is simple, because there are no carries:

`10100`

______`+ 1`

`10101`

This matches what we did with the fingers: we just raised the thumb.

The rule for fingers (find the smallest-position finger that’s
down, raise it, and lower all smaller-position fingers) corresponds to
finding the rightmost **0**, changing it
to a **1**, and replacing any **1**s to the right with **0**s. That’s exactly what the carries do, as you
can see in the first addition.

### End Notes

Mentat Wiki. “Physio Arithmetics.” http://www.ludism.org/mentat/PhysioArithmetics.

Mark Purtill

## Estimate Orders of Magnitude

**By using rough order-of-magnitude estimates,
you can check calculations and estimate whether tasks are even plausible
before spending time to plan them more accurately.**

An *order-of-magnitude estimate* is an
estimate to the nearest power of 10. For instance, an order-of-magnitude estimate
of 400 means the true value is closer to 400 than 40 or 4,000. The
estimates we’re discussing in this hack are called *rough order-of-magnitude* (ROM) estimates
because we’re not completely sure we’re within an order of
magnitude.

Other terms for this kind of estimate are *ballpark estimates* (as in, “Are we
even in the ballpark?”) and *educated* or *scientific
wild-ass guesses*. As all of these names suggest, the idea is
to determine roughly how large a number is, or whether a task is
trivial, possible, or absurd.

### Warning

When you’re estimating tasks, make sure everyone understands
that ROM estimates are just that. They should *not*
be written into contracts or used as targets when actually doing work.
That needs more careful estimation and project tracking. ROM estimates
are just to know whether to bother performing a more formal
estimate.

### In Action

First, let’s do a purely numeric hack: estimate how many seconds are in a year.

There are 60 seconds in a minute and 60 minutes in an hour; multiplying them is easy: 3,600 seconds in an hour. Let’s round that to 4,000. Twenty-five percent might seem like a big round-up, but we are concerned here with orders of magnitude; as long as it’s not 2,500%, we should be OK.

Now, there are 24 hours in a day. We rounded the seconds in an hour up, so let’s round this down to 20. Multiplying 20 by 4,000, we get 80,000 seconds in a day, which we can round up to 100,000.

There are 365 days in a year (plus a bit). Let’s round that to 400. Our final estimate (400 days times 100,000 seconds) is 40,000,000 seconds in a year, and since we rounded up three times and down once, it’s probably high rather than low.

### Tip

The actual answer, using 365.2422 days per year, is 31,556,926 seconds per year, so we are well within an order of magnitude (and we were indeed high, not low).

Now, let’s do a similar problem estimating a task. In an episode
of *The Simpsons* I just saw in syndication, Bart
is in France as an exchange student for three months, but he ends up
picking grapes at a run-down chateau. Supposedly, he picks a million
grapes in that time (this is an estimate by one of the Frenchmen
exploiting Bart).

First, let’s see if 1,000,000 grapes seems plausible. Each bunch of grapes has some grapes on it—more than 10, certainly. Let’s say 100. Each vine will have several bunches; let’s say 10. So, we’ve got 1,000 grapes per vine, which means 1,000,000 grapes require 1,000 vines. If anything, that seems low for the vineyard pictured, so no problems here.

Could Bart even theoretically pick all those grapes in less than three months? Let’s say Bart picks one grape per second, which seems plausible (he certainly doesn’t manage 10 in a second, but he can do more than one every 10 seconds). At this pace, he’d manage 3,600 in an hour. Let’s round that down to allow time to move between bushes, empty the container, and so on, but to compensate, we’ll have him work 20 hours a day. So, Bart manages 60,000 (20 × 3,000) grapes a day. If we round that to 50,000 to get a nice factor of 10 [Hack #36], we see it will take 20 days (1,000,000 / 50,000, which is the same as 1,000 / 50) to harvest 1,000,000 grapes.

This is somewhat less than three months (which is about 3 × 30 = 90 days). So, an estimate of three months seems somewhat reasonable even though it was intended as humorous exaggeration—but there were a lot of guesses in there. If this were important, it would be worth doing a more careful analysis of things, such as Bart’s grape-picking speed

### How It Works

The basic idea is to estimate anything you don’t know and round off numbers to make the arithmetic easy. As you estimate and round, if you keep track of whether you’re estimating high (rounding up) or estimating low (rounding down), you get a feeling as to whether your estimate is more likely to be high or low.

Rounding up one time and down the next will tend to cancel out (though of course this depends on how much you’re rounding). That’s just because using a bigger number in one place will cancel out using a smaller number in another. For instance, when computing the seconds in a day, we rounded 3,600 up to 4,000 and 24 down to 20, and multiplied them to get 80,000. The actual answer is 86,400 (3,600 × 24), and we’re quite close. Notice that if we’d rounded both numbers up—say, to 4,000 × 30—we’d get 120,000, which of course is higher, but also further away from 86,400 than 80,000 is. Likewise, rounding both down—say, to 3,000 × 20—gives us 60,000; again, further away than 80,000.

Sometimes, you want to mostly round up (if it’s work you’re going to have to do) or mostly round down (if you’re estimating feasibility). You might want to do both and use the two numbers as upper and lower bounds. For instance, in the example of the number of seconds in a year, we’d know that the number of seconds in a day is between 60,000 and 120,000.

### In Real Life

ROM estimates can help you find mistakes in everyday life. They can help you in your job, and they might even help you get a job if you don’t have one.

#### Checking calculations

Mistakes on calculators can easily give answers that are wildly wrong. For instance, suppose we were computing the number of seconds in a year, and we typed this:

60 * 60 + 24 * 365

to get this:

12360

Since our earlier estimate when we tried to calculate the number of seconds in a year was 40,000,000, we know something went wrong.

#### Work estimates

At my work, we often use ROM estimates to figure out how long a customer request will take. We estimate tasks by week and add them up to get the total time. We can then compare that to the customer’s schedule and budget.

Suppose, for instance, that someone asks Ron to write another book of mind performance hacks, but they want it in two months. Can he do it?

The book will comprise about 10 chapters with about 10 hacks in each chapter, for a total of 100 hacks (which might be an overestimate, but it’s a nice, round number to shoot for). Some hacks are easier than others are, but we might say that, on average, each takes two hours to research, two hours to write a first draft, an hour for polishing, and an hour for technical review. That’s six hours for each hack, for a total of 600 hours. At 40 hours per week, we already have 15 weeks, well more than two months. So, we can already tell that Ron will need some help, and we haven’t counted the time to decide which hacks to use.

The task of deciding which hacks to write should also be figured in and is the kind of thing we tend to like to be generous in estimating, because it’s hard to quantify. It’s much harder to say, as we did with the writing, that it will take a definite amount of time per hack to think them up, and that time will probably have to be spread out more. On the other hand, we have some hacks in this book that might help.

#### Job interview

Many software companies like to ask mind-expanding questions to prospective hires to test their ability to think big and creatively. One famous example is, “How would you move Mount Fuji?” Let’s estimate the number of truckloads of dirt that would generate.

First, how tall is Fujisan? If you know, you can round that off, but I don’t. It’s a very tall mountain, so it’s probably around 10,000 feet. Again, 1,000 is definitely too small and 100,000 is too big. But 20,000 would be equally plausible for this kind of estimate, or even 30,000, though that would make Mount Fuji taller than Mount Everest. If you’d rather work in the metric system, 5,000 meters or 10,000 meters would be a good estimate, which of course doesn’t match the estimates in feet.

### Tip

According to Wikipedia, Mount Fuji is 3,776 meters (12,388 feet) tall. So our 10,000-foot estimate isn’t too bad.

Anyway, let’s stick with 10,000 feet for now. Mount Fuji appears to be roughly a cone, with the base diameter about twice the height. (If you look at a picture of the mountain, you’ll see the base is actually quite broad.) So, if we knew the formula for the volume of a cone, we’d be all set.

First, let’s suppose we don’t; all we remember is the volume
of a cube, which is the side cubed. If we visualize a cube as high
as the mountain, it looks *roughly* the same. For
a ROM estimate, that’s probably good enough, and the cube’s volume
would be 1,000,000,000,000 cubic feet
(10,000^{3} =
10^{12}).

If you do remember a bit more geometry, you’ll recall that the
volume of a cone is (area of base) × height / 3, and the area of the
base is π × r^{2}. Since we estimated the
diameter of the base as twice the height, the radius (r) of the base
is the same as the height. Putting this all together, we get π ×
height^{2} × height / 3. And, since π is
about 3, we end up with 1,000,000,000,000 cubic feet
(10,000^{3} =
10^{12}) again.

OK, how much can a truck haul away? Probably a volume of 10 × 10 × 10 is not unreasonable (trucks aren’t 10 feet wide, but they could be longer and that should make up for the width). So, one truckload is 1,000 cubic feet.

We would need 1,000,000,000,000 / 1,000 = 1,000,000,000 (one U.S. billion) truckloads, which is a lot. In this case, of course, there are many other problems with moving Fujisan; for instance, the Japanese people would probably object!

Mark Purtill

## Estimate Square Roots

**Estimate square roots and even higher-order
roots by using simple processes.**

It’s often useful to compute the square root of a number, especially when you want to visualize areas or compute diagonal distances. There are a few methods for computing square roots on paper, some of which are not widely known. If all you have is your brain, however, it’s still possible to come up with a quick estimate that’s reasonably accurate.

### In Action

To estimate the square root of a number, start by pairing up the digits of the number, beginning with the decimal point and moving away. So, for instance, to compute the square root of 500,000, we would pair up the digits like this:

50 00 00

Each pair of digits will, in fact, represent a digit in the square root. The leftmost pair of digits (or single digit, if there are an odd number of digits in your original number) is used to compute the leftmost (most significant) digit of the result. You find the result digit by determining the highest square that will fit into the pair without going over.

The biggest perfect square that fits into 50 is 49, which has a
square root of 7. So, we know our square root will have the form
`7dd`

—that is, a `7`

followed by two digits, or “seven hundred
and something.” Further, since 50 is very close to 49, we can surmise
that the square root will be in the low 700s. Had it been close to the
next square (64, with a square root of 8), we would know that the
square root would be closer to 800. Unfortunately, computing the exact
value of the later digits requires pencil and paper, but our estimate
is in the ballpark.

What about numbers smaller than 1? Basically, the same method applies. You still pair up digits going away from the decimal point, and the most significant digit will still be the square root of the biggest square that fits into the leftmost pair of digits. So, to compute the square root of 0.0038234, you would pair up the digits like so:

00 . 00 38 23 40

Each pair of digits again represents a single digit in the answer, and the decimal place stays where it is. The biggest square that fits in 38 is 36, with a root of 6. So, your square root will be 0.06.... Since 38 is close to 36, we can also surmise that our approximation is already pretty close to the answer, so the next digit will be small.

#### Very large and very small numbers

Numbers in science and engineering are often expressed in scientific notation, which is a convenient way to express astronomically large or small numbers. With scientific notation, numbers are expressed in the form:

a × 10^{b}

where `a`

is usually in the
range `1 <= a < 10`

, and
`b`

is an integer. Nearly all
modern calculators use scientific notation for representing
large or small numbers; typically, the `10`

is omitted and the letter `E`

for "exponent” is used (e.g., `5.2349 E+41`

). Since the exponent tells us
the number of digits, we can use a very similar method to estimate
the square root of some very large or very small numbers.

When the exponent `b`

is
even, it’s easy to come up with an estimate. Simply estimate the
square root of the `a`

part and
halve the exponent. So, given a number like 5.8345 ×
10^{82}, we can immediately tell that the
square root is going to be 2.d × 10^{41},
because:

4 is the biggest square that fits in 5.

4 has a square root of 2.

The exponent 41 is half of 82.

This works for both positive and negative even exponents.

When the exponent `b`

is odd,
we need to borrow the first digit from the other side of the decimal
point of `a`

. Estimate the square
root of that, and you have the `a`

part of the result. To get the exponent of the result, subtract 1 from the exponent
of your original number before halving it.

For instance, given 5.0234 × 10^{17},
we would find the square root of the biggest square that fits in 50
(49, with a square root of 7) and subtract 1 from the exponent 17 to
make it 16 before halving it, giving us a square root of 7.d ×
10^{8}.

For a number with an odd *negative*
exponent, such as 1.9123 × 10^{-43}, you
will still subtract 1 from the exponent before halving (-43 to -44);
since 4 is the closest square root to 19, the answer will be 4.d ×
10^{-22}.

#### Higher roots

What about cube roots, fourth roots, and so on? There is a more general rule
that will let you estimate these. Instead of pairing up the numbers,
to compute the *n*th root of a number, divide its
digits into groups of *n* digits each, going away
from the decimal point. So, to compute the fourth root of
7,324,643,245, group it like this:

73 2464 3245

As before, each group represents one digit of the result. And
the first digit will be the number closest to the fourth root of the
first group, 73. While there is no easy way to compute or memorize
the fourth roots of numbers, remember that it can be only
one of nine possible digits, so it is fairly easy to find it via
trial and error. 2 × 2 × 2 × 2 is 16; 3 × 3 × 3 × 3 is 81, which is
a little too large. So, our answer will be `2dd`

, a number in the high 200s. As you’ve
probably realized, the method for computing square roots described
earlier is just a specific (*n *= 2) example of
this more general method.

### In Real Life

Suppose you come across a real estate listing advertising a house with an area of 3,700 square feet. Breaking this up into pairs of digits gives you:

37 00

You have two groups, so it’ll be a two-digit number. The largest square that fits into 37 is 36, with a square root of 6. And it’s pretty close, so this house will have as much floor space as a square house a little longer than 60 feet on a side.

It was recently reported that the ozone hole over Antarctica has shrunk to 6,000,000 square miles. How big is this? Breaking this up into pairs of digits gives you:

6 00 00 00

The biggest square that fits into 6 is 4 (2 × 2), so you should be able to determine, with a moment’s reflection, that this represents a square area measuring in the middle 2,000s on each side. Still a pretty big hole in the ozone!

### Tip

If you’d rather picture a circle, it will always have a diameter that’s about 13% bigger than the square root you just estimated.

Also in the news at this writing, Hurricane Katrina reportedly left an estimated 16 million cubic yards of debris littering the coastline of Mississippi alone. How big a warehouse would it take to hold all of that? Because it’s cubic, we gather the digits in groups of three:

16 000 000

That’s three digits, and the cube root of 16 is somewhere
between 8 (2 × 2 × 2) and 27 (3 × 3 × 3), so this represents a cube
that’s about 250 × 250 × 250 *yards*. That’s a
warehouse wider, longer, and taller than two football fields, and
that’s just the debris littering Mississippi.

### See Also

Wikipedia. “Square root.” http://en.wikipedia.org/wiki/Square_root. A good summary of more traditional methods of estimation and exact computation of square roots, including the exact method that this estimation method is based on. Go there to learn how to compute a square root exactly, with the help of pencil and paper.

Doerfler, Ronald W.

*Dead Reckoning: Calculating Without Instruments*. Gulf Publishing Company. Contains further methods for computing roots.

Mark Schnitzius

## Calculate Any Weekday

**Quickly calculate the day of the week for
any date of the Gregorian calendar—useful for scheduling appointments
and meetings!**

The imperfect Gregorian calendar, when combined with the imperfect Earth year—which is an even multiple of neither 12 (the number of months) nor 7 (the number of days in the week), but instead an icky 365.24237404 days long (approximately!)—means that, for most of us to find what day of the week a meeting falls on, we have to consult a wall calendar or our PDA.

But what if you had your own perpetual calendar in your head? What if you could, with practice, take just a few seconds to calculate any day of the week from centuries ago and into the distant future, when they finally nudge the Earth into a more reasonable orbit?

You can. Here’s how.^{1,2}

### In Action

To calculate any weekday, you basically need to find four
numbers, add them together, and then *cast out sevens* (i.e., calculate
that number *modulo 7*, a simple procedure). In
practice, you can do the modulo math as you go along to keep the numbers small
and simply keep a running total.

Here are the numbers you need:

The year-item

The month-item

The day-item

Adjustment

#### The year-item

Finding the year-item (or *key number* for
the year) is easy. Here’s the formula:

(YY + (YY div 4)) mod 7

where `YY`

represents the
last two digits of the year.

#### The month-item

Finding the month-item requires some memorization. There are only 12 key numbers, though, one for each month, as shown in Table 4-10.

Month | Key number |

January | 0 |

February | 3 |

March | 3 |

April | 6 |

May | 1 |

June | 4 |

July | 6 |

August | 2 |

September | 5 |

October | 0 |

November | 3 |

December | 5 |

To memorize these numbers, you can use any mnemonics that you prefer, such as the Dominic System [Hack #6].

#### The day-item

The day-item is simply the day of the month—for example,
`1`

for April 1, `31`

for October 31, `15`

for March 15, and so on.

#### Adjustment

The fourth number you will need to find is an adjustment to the total. It has two parts: the century-item, plus a possible tweak if the year is a leap year.

Since you’ll mostly be finding dates in the 20th and 21st centuries, you can probably ignore most of Table 4-11, and just remember that for dates from 1900–1999, the adjustment is 0 (that is, don’t add anything), and for dates from 2000–2099, you add 6.

A more precise method follows.

The Julian calendar ended in most Western countries on September 2, 1752, and the Gregorian calendar began on September 14, 1752.

### Tip

They had to fudge the date when they converted over. Legend
has it that people rioted for their *lost
days*. And you thought Y2K was a big deal.

To get the century-item for any date on the Julian calendar, subtract the century (which would be 14 for the year 1492) from 18, and cast out sevens.

To get the century-item for any Gregorian year up to 9999, take the first two digits of the year, cast out fours, subtract the result from 3, and multiply the difference by 2. Thus, for the year 2008:

20 mod 4 = 0 3 - 0 = 3 3 × 2 = 6

And 6 is indeed the century-item for the 2000s, as shown in Table 4-11.

Now for the leap-year tweak. If your date is in January or February of a leap year, subtract 1 from the running total.

Any year evenly divisible by 4 in the Gregorian calendar is a leap year, except that years also divisible by 100
aren’t—except that years *also* divisible by 400
*are* leap years. Thus, 1936 was a leap year (it
is evenly divisible by 4); 1937 was not a leap year (it’s not
divisible by 4). The years 1800 and 1900 weren’t leap years (they’re
evenly divisible by 100), but 2000 was (it’s also evenly divisible
by 400).

Leap years in the Julian calendar are simply any year divisible by 4.

#### What to do with the result

If you have *cast out all sevens* (that is,
calculated the number `mod`

`7`

correctly), the end result will
be a number from 0 to 6. This number will tell you the weekday,
starting with Sunday at 0 and counting upward, as shown in Table 4-12.

### In Real Life

Let’s calculate the weekday of the first moonwalk, July 21, 1969:

The key number for the year is

`(69`

`+`

`(69`

`div`

`4))`

`mod`

`7`

.`69`

`div`

`4`

`=`

`17`

, because`69`

`/`

`4`

`=`

`17`

with a remainder of 1 (or`17r1`

).`69`

`+`

`17`

`=`

`86`

.Now, cast out sevens:

`86 mod 7 = 2`

, because the next highest multiple of 7 is 84, and`86`

`–`

`84 = 2`

.*Remember the number 2*.The key number for the month of July is 6 (see Table 4-10). Add that key number to the result you remembered in the previous step:

`6`

`+`

`2`

`=`

`8`

.Cast out sevens:

`8`

`mod`

`7`

`=`

`1`

. (7 goes into 8 once, with 1 left over.)*Remember the number 1*.The key number for the day is 21, because the first moonwalk took place on July 21. Add the result you remembered in the previous step:

`2`

1`+`

`1`

`=`

`22`

.Cast out sevens:

`22`

`mod`

`7`

`=`

`1`

.The adjustment is 0, because this took place from 1900–1999 and it was not January or February of a leap year:

`1`

`+`

`0`

`=`

`1`

.The final result is

`1`

, so the first moonwalk took place on a Monday. (And consulting a calendar, we find that this is true!)

To be precise, the moonwalk took place at 2:39:33 A.M. UTC, which was Sunday night throughout the U.S. I bet the workers of the world had quite a bit to talk about around the water cooler the next day.

### End Notes

Carroll, Lewis. “Lewis Carroll’s Algorithm for finding the day of the week for any given date.” http://www.cs.usyd.edu.au/~kev/pp/TUTORIALS/1b/carroll.html.

Mentat Wiki. “Calendar Feat.” http://www.ludism.org/mentat/Calendar Feat (explains several different ways to calculate the date, and many shortcuts).

### See Also

“Use the Dominic System” [Hack #6] uses memorization of the month-item table as an example.

If the World Calendar were adopted, the same date would always have the same weekday in every year. Simple, flexible, logical, and utterly unlikely to be adopted, it’s the Esperanto [Hack #51] of calendars! (See http://personal.ecu.edu/mccartyr/world-calendar.html.)

Get *Mind Performance Hacks* now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.