You are on page 1of 5

Divisibility by 7:

Now we will study divisibility by 7. One book on speed arithmetic says that these tests
are just too complicated, and you should just divide by 7. I agree to some extent, but my
calculator still will not let me enter really large numbers.

One interesting way (found in some books) is to take the two left-most digits, multiply
the left digit by 3 and add it to the second digit. Replace these two digits with the result.
Then we can keep repeating, always dealing with only the two left-most digits, until we
end up with a small number which is either divisible by 7 or not. Pretend we have a two
digit number, 10x+y. We multiply the left digit by 3 and add the second digit: 3x+y. All
we did was just subtract 7x. If 3x+y is divisible by 7, then so is 10x+y. This works at the
left end of a long number, too. The two left-most digits are 10x+y times some power of
10. Multiplying the left digit by 3 and adding the second digit gives us 3x+y times the
same power of 10. And we subtracted off 7 times the same power of 10. Again,
divisibility by 7 was not altered.

4712954379
1912954379
1212954379
512954379
162954379
92954379
29954379
15954379
8954379
3354379
1254379
554379
204379
64379
22379
8379
2779
1379
679
259
119
49

49 is divisible by 7. We could have stopped the process once we got a number that was
small enough for my calculator, and divided the current number by 7. Since 49 is
divisible by 7, every number above it is also divisible by 7.

Modular arithmetic gives us the following method. Start at the right digit, and go left. 1st
digit + 3 times the 2nd digit + 2 times the 3rd digit - the 4th digit - 3 times the 5th digit -
2 times the 6th digit. And then we repeat the sequence, + the 7th digit + 3 times the 8th
digit, etc. If the whole "sum" is divisible by 7, then the original number is divisible by 7.
4712954379
9+3(7)+2(3)-4-3(5)-2(9)+2+3(1)+2(7)-4=14

14 is divisible by 7. You can see that this is a much faster method. With really huge
numbers, you might need to repeat the above steps.

I use a different method. I separate the huge number into 6-digit numbers (4712 954379),
add them together (4712+954379=959091). I use my calculator to divide this by 7, and
there is no remainder (959091/7=137013 with no remainder), so the original number is
divisible by 7. With really huge numbers, I may have to repeat these steps. This method
works for divisibility by 13, by the way. The above number is not divisible by 13. Why
do we separate the number into 6-digit numbers? Well again, modular arithmetic
produces that information. For divisibility by 37, we separate the long number into 3-
digit numbers.

Addendum:

I received email from Jordan Baker, describing another test for divisibility by 7: "Take
the last digit off, double it, and subtract it from the rest of the numbers. If the result is
divisible by 7, so was the original number." And that can be repeated, of course. He gave
this example: "Take a number like 408254, which is divisible by 7. Take the 4 off the end,
and double it: 8. 40825 - 8=40817." Then he repeated the process.

Here is my explanation of why this works:

A many digit number is 10x+y (for example, 3176 is 317(10)+6). 10x+y is divisible by 7
if and only if 20x+2y is divisible by 7 (that is twice the original number, doubling it does
not affect its divisibility by 7, as 2 and 7 are relatively prime). We can subtract 21x from
20x+2y without affecting its divisibility by 7 (21x is divisible by 7). That gives 2y-x
(which is usually a negative number, by the way). So, 10x+1 is divisible by 7 if and only
if 2y-x is divisible by 7. The method that Mr. Baker showed me was x-2y, which is -(2y-
x). So 10x+1 is divisible by 7 if and only if x-2y is divisible by 7.

I thought that I had seen that method before. Here is actually what I had seen before,
from The Dictionary of Curious and Interesting Numbers, by David Wells: Multiply the
right-most digit by 5 and add to the rest of the numbers. If this sum is divisible by 7, then
the original number is divisible by 7. And that too can be repeated. This is a slow method.
It is roughly as fast as the above methods (3x+y and x-2y) until near the end, and then it
can take 5 or 6 extra steps. Also, if you end up with 49, you get no further, as the next
number is also 49. Otherwise, you can keep repeating the process until you get a one digit
number (7). Why does it work?

Our original number is 10x+y. We can multiply that by 5 without affecting its divisibility
by 7: 50x+5y. We can subtract off 49x (which is divisible by 7) without affecting its
divisibility by 7: x+5y. And x+5y is the method described.
7a. , , , , , (mod 7), and the
sequence then repeats. Therefore, if
is divisible by 7, so is .
This method was found by Pascal .

7b. An alternate test proceeds by multiplying by 3 and adding to ,


then repeating the procedure up through . The final number can
then, of course, be further reduced using the same procedure. If the
result is divisible by 7, then so is the original number (Wells 1986, p.
70).

7c. A third test multiplies by 5 and adds it to , proceeding up


through . The final number can then, of course, be further reduced
using the same procedure. If the result is divisible by 7, then so is the
original number (Wells 1986, p. 70).

7d. Given a number, form two numbers and such that consists of all
digits of the number except the last (units) digit and is the last digit.
Compute and repeat the procedure. Then the original number is
divisible by 7 iff the number in the last step is divisible by 7.

We know that to test for divisibility by (say) 15, we need only test for divisibility by 3
and 5. It follows that only the prime divisibility tests are required.

All the methods here work in the same recursive way. The number N1 is a multiple of
prime P if (and only if) the smaller number N2 is also a multiple of P. These algorithms
provide a way of reducing N1 to N2 (and N3, N4 etc.) until a multiple of P is recognised.

Some examples

We wish to test the number 742 (N1) for divisibility by 7. We get to the smaller number
(N2) by chopping off the units digit, multiplying it by 5 and adding it to the number of
tens in the orginal number (N1):

742 -> 74 + (2 x 5) = 84, which is clearly a multiple of 7

Therefore 742 is also a multiple of 7.

Another example. Is 3647 divisible by 7?

3647 -> 364 + (7 x 5) = 399

399 -> 39 + (9 x 5) = 84, which is a multiple of 7.


Therefore 3647 is also a multiple of 7 (and incidentally, so is 399).

I shall call this algorithm "Multiply by 5 and add".

The algorithm "Multiply by 2 and subtract" also works as a test for divisibility by 7:

3647 -> 364 - (7 x 2) = 350

350 -> 35 - (0 x 2) = 35, which is a multiple of 7

Therefore 3647 is also a multiple of 7 (and incidentally, so is 350).

These two algorithms form a "conjugate pair", one being "add" and the other being
"subtract", as well as one being "multiply by m" and the other being "multiply by (p-m)",
where p in this case is 7.

All this is leading up to the remaining divisibility tests. Each one uses the basic procedure
of chopping off the units digit, multiplying it by m [or (p-m)] and then either adding to or
subtracting from the truncated number.

Why These Methods Work

The simplest explanation, which is usually good enough for children, is that the
procedure is just a fancy way of doing division by "chunking" - i.e., removing known
multiples and just testing the remainder.

The Real Reason

The algorithm creates a smaller number that is a multiple of the prime being tested if and
only if the original number was also a multiple. The explanation for the 7 test:

The original number (N1) can be written in the form 10a + b. For example, if N1 is 742
then a = 74 and b = 2.

Let's assume that 10a + b is a multiple of 7. Then 10a + b = 7k for some integer value of
k.

Then b = 7k - 10a.

And a + 5b = a + 35k - 50a = 35k - 49a = 7 (5k - 7a)

So this is clearly a multiple of 7 as well.

The General Procedure


The trick is simply to find the multiplying factor (m) for each number (p) to be tested.
Playing with the algebra reveals that m is simply the first integer for which 10m-1 is
divisible by p. The conjugate factor (p-m) is similarly the first integer for which 10(p-
m)+1 is divisible by p. This gives the following table:

Divisibility Factor Conjugate Factor Best Algorithm


Test (p) (m) (p-m)
7 5 2 x5 and add
11 10 1 x10 and add
13 4 9 x4 and add
17 12 5 x5 and subtract
19 2 17 x2 and add
23 7 16 x7 and add
29 3 26 x3 and add
31 28 3 x3 and subtract
37 26 11 x11 and subtract
41 37 4 x4 and subtract
43 13 30 (either)
47 33 14 (either)
53 16 37 (either)

Let’s use the table to test whether 3534 is divisible by 31. The algorithm is "Multiply by 3
and subtract":

3534 -> 353 - (4 x 3) = 341

341 -> 34 - (1 x 3) = 31 which is a multiple of 31

Therefore 3534 is divisible by 31.

You might also like