Hack #37. 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 31/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.

  1. Every integer is divisible by 1.

  2. 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.

  3. 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).

  4. 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).

  5. 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).

  6. 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.

  7. See the "Divisibility by 7" sidebar.

  8. 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).

  9. 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).

  10. If the last digit of a number is 0, the number is divisible by 10. Example: 99,310 (the last digit is 0).

  11. 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.

  12. 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.

  13. 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.

  14. 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.

  15. 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

  1. 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.

  2. 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.

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.