# Divisibility test by 7

Pohlmann-Mass method

Step A: If the integer is 1,000 or less, subtract twice the last digit from the number formed by the remaining digits. If the result is a multiple of seven, then so is the original number.

Isn't this step enough to check divisibility by 7 for all numbers. But then why wikipedia mentions step B for numbers greater than 1001 as following.

Step B: If the integer is between 1,001 and one million, find a repeating pattern of 1, 2, or 3 digits that forms a 6-digit number that is close to the integer (leading zeros are allowed and can help you visualize the pattern). If the positive difference is less than 1,000, apply Step A. This can be done by subtracting the first three digits from the last three digits.

Where step A fails?

• It does not fail at all. Where did you read this? Dec 26, 2014 at 15:28
• As Roos has written, Step B is just for accelerating the process in Pohlmann-Mass method. :) Dec 26, 2014 at 15:33
• @BhaskarVashishth Just to clarify: you did not read it in Wikipedia. Wikipedia says that for bigger numbers you can (and should) apply another method of faster convergence, not that the first method 'fails'. Jul 2, 2015 at 23:15

Step A works fine for all numbers. You can repeat it as many times as desired. The disadvantage is that it only decreases the number by one digit per step. Step B reduces the length of the number by three digits per step (most of the time), so you might find it easier. So if you start with $abcdef$, if $def \gt abc$ you subtract $abc * 1001 =abcabc$ and get $def-abc$, which has the same remainder on division by $7$. If $abc \gt def$, you subtract $(abc-1)*1001$ for the same result.

Let $n$ be your number and let $$n=10a+b.$$ Suppose$$7r=a-2b.$$ Then $$n=10(7r+2b)+b=7(10r+3b).$$ Therefore your test is valid for any positive integer $n$ and also note that $b$ should not always be last digit. Some times it can be last two or three digits.

As $21x-2(10x+y)=x-2y,2(10x+y)\equiv2y-x\pmod7,$

we can safely apply this reduction method.

Again for $x_0+x_110^3+x_2(10^3)^2+\cdots+x_n(10^3)^n,$ where $0\le x_i<1000$

as $10^3\equiv-1\pmod7,10^6\equiv1$

$x_0+x_110^3+x_2(10^3)^2+\cdots+x_n(10^3)^n\equiv x_0-x_1+x_2+\cdots+(-1)^nx_n\pmod7$

The point of the observation about $1001$ is that $1001=7\times 11\times 13$ and eliminating multiples of $1001$ from numbers of many digits is a quick and easy fix. You can also replace any digit $7$ by $0$ (for which adding multiples of $1001$ might help)

So the point is to use the simplest and most efficient method