I’ve been working on another puzzle post, which will eventually show up here (but probably first on Rworks). Because the puzzles I present come from older sources---in this case, Strand Magazine from 1924---I try to solve the puzzles using techniques that a puzzle-solver would have access to at the time—in other words, techniques other than brute force search via computer.
While looking for such a solution to the current puzzle, I started
thinking about various tricks for eyeballing the divisibility of
integers. You probably remember these tricks from grade school: a number
Here are a couple of tricks that I didn’t know, until I started looking into this topic:
is divisible by 4 if its last two digits are divisible by 4. is divisible by 8 if its last three digits are divisible by 8.
These are both specific cases of the general rule
is divisible by if its last digits are divisible by .
So in this post, I’ll prove it, and provide a few examples of using the rule for mental or pencil-and-paper calculations, just for fun.
The Proof #
Let
As an example, if
Any integer where the lowest
The next step is to establish that
Now
Going back to our example, 734 is not divisible by 4, because 34 isn’t. But 732 is.
is_divisible_by = function(M, m) {
if(M %% m == 0) {
result = paste(M, "is divisible by", m)
} else {
result = paste(M, "is not divisible by", m)
}
result
}
is_divisible_by(734, 4)
## [1] "734 is not divisible by 4"
is_divisible_by(732, 4)
## [1] "732 is divisible by 4"
Notice that in proving the above, we also established that
is divisible by if its last digits are divisible by .
So those are some divisibility tricks you may not have known. Let’s try applying them.
Fun with Mental Calculations #
All of the operations below should be doable in your head, or with the help of a pencil and the back of an envelope.
Is M = 9,937,654,480 divisible by 8? #
Since
# check
M = 9937654480
is_divisible_by(M, 8)
## [1] "9937654480 is divisible by 8"
Is M = 9,937,654,480 divisible by 16? #
We know 480 is divisible by 8, from above. We can break 4480 down into
560 is divisible by 2. So 4480 is divisible by 2*8 = 16, which is what
we want. Therefore,
is_divisible_by(M, 16)
## [1] "9937654480 is divisible by 16"
As an aside, 560 is also divisible by 4 (because 60 is divisible by 4), and by 8. So we also know that 4480 is divisible by 32 and by 64.
is_divisible_by(4480, 32)
## [1] "4480 is divisible by 32"
is_divisible_by(4480, 64)
## [1] "4480 is divisible by 64"
Is M = 9,937,654,480 divisible by 32? #
We know from above that 4480 is divisible by 32, so now we need to check
if 50,000 is divisible by 32. We know it’s divisible by 8 (because 000
is divisible by 8), and if we have an envelope and a pencil handy we can
calculate that
Now, we can eyeball that 6250 is not divisible by 4 (because 50 is not
divisible by 4). So 50,000 is not divisible by 32. Therefore
is_divisible_by(54480, 32)
## [1] "54480 is not divisible by 32"
is_divisible_by(M, 32)
## [1] "9937654480 is not divisible by 32"
Fun, but is it Practical? #
In an era of calculators and computers, the math fact we just proved has
limited value, since it’s just as easy to divide the full number by
And it’s fun to exercise your brain with mental arithmetic or pencil and paper calculations, once in a while.