Division by 7, the Moura Velho Method

This week, Silvio Moura Velho showed me a new method for determining if a number is divisible by 7 (and by 13).  The method is described at: http://www.7and13divisibility.com/. I am impressed at how quickly the method works.  What I feel is missing on the site is a good explanation as to why it works.  (The "Why it works" tab seems to only provide another example.)  Can you explain succinctly why this method works?

Source: Original.


Solutions were received from Jayavel Sounderpandian and Joseph DeVincentis.  My solution precedes theirs below.
Ken's solution, taken from a note to Silvio 8/18/05:

Consider a 6-digit number FEDCBA. This can also be seen as:

A +10B +100C +1000D +10000E +100000F

The new number you're creating through your method is:

A + 10B + 9C -D -10E -9F (plus the needed multiples of 7 or 13 to remain positive)

Compared to the orginal number, the new one is:

(no change in A and B)
-91 C
-1001 D
-10010 E
-100009 F or (-100100 + 91) F

All of these are multiples of 91, which is divisible by both 7 and 13. So the divisibility for those numbers is unchanged.

For larger digit numbers, you've simply divided anything above 6-digits by one million and repeated the process. Dividing by one million is the same as subtracting 999999 times the number, which is also divisible by 7 and 13, so it's again not changing the divisibility.


Jayavel's solution:

I shall first explain why the method for divisibility by 7 works.

The modulo 7 values of the sequence 1, 10, 100, … is:
1, 3, 2, 6, 4, 5, 1, 3, 2, 6, 4, 5, … where the six numbers repeat themselves.

The first digit that the method computes assigns the following six repeating values to the successive decimal places:
1, 0, -1, -1, 0, 1
Because 10 mod 7 = 3, the second digit that the method computes assigns the following six repeating values to the successive decimal places:
0, 3, 3, 0, -3, -3
Adding the two we get
1, 3, 2, -1, -3, -2
which in modulo 7 is the same as
1, 3, 2, 6, 4, 5.
Hence the method must work.

Surprisingly, testing divisibility by 13 reduces to analyzing 6 repeating residuals similarly, and the method works. This happens because of the combination of the facts:
10 mod 7 = 3
10 mod 13 = -3
10^6 mod 13 = 1
13 mod 7 = -1
Joseph's solution:

A restatement of the method is as follows:

Add and subtract digits of the number in the following pattern, repeating to the left:
... +0--0++0--0++0--0+
The result mod 7 is the ones digit.
Add and subtract digits of the number in the following pattern, repeating to the left:
... --0++0--0++0--0++0
The result mod 7 is the tens digit.
If the resulting two-digit number is divisible by 7, the original number is divisible by 7.

So, consider the pattern, mod 7, of the multiples of each digit which are applied to produce this two-digit result. (Use only the last 6 digits for simplicity.)
The contribution from the ones digit of the result (where -1 = 6 mod 7, of course):
1, 0, 6, 6, 0, 1
The contribution from the tens digit (since the result here is multiplied by 10, each unit adds 10 = 3 mod 7 to the total):
4, 4, 0, 3, 3, 0
The sum of the contributions, mod 7:
5, 4, 6, 2, 3, 1

Now consider the place value for each position, mod 7:
100000, 10000, 1000, 100, 10, 1
5, 4, 6, 2, 3, 1
And 1,000,000 mod 7 is 1 again and the pattern repeats.
Thus the method preserves the value of the original number mod 7.
The method of multiplying the digits of the number by these mod values in succession (with negatives for the numbers greater than 3) and adding up the results is cited in the "Why it works" as an alternative method of finding divisibility by 7, but is deemed more difficult to remember or use. (I guess to use, because 1, 3, 2, -1, -3, -2 is hardly a difficult sequence to remember.)
Mail to Ken