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.
Every integer is divisible by 1.
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 + ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access