Proving a particular divisibility rule for 7 I came across this rule of divisibility by 7:

Let N be a positive integer. Partition N into a collection of 3-digit numbers from the right (d3d2d1, d6d5d4, ...).
N is divisible by 7 if, and only if, the alternating sum S = d3d2d1 - d6d5d4 + d9d8d7 - ... is divisible by 7.

I'm trying to prove this rule. Though I'm sure this might be done using modular arithmetic, I haven't reached anything useful. I have searched for a proof and haven't found one. Any idea or hint will be appreciated. 
Thanks a lot.
 A: This is because $10^3\equiv -1 \pmod 7$. Notice that what we're doing when cut up the decimal expansion of a number $n$ like that is saying that, where $a_0$ is the first three digits, $a_1$ is the next, and so on:
$$n= a_0+10^3a_1+(10^3)^2a_2+(10^3)^3a_3+\ldots$$
but, looking at this mod $7$ gives
$$n\equiv a_0+(-1)a_1 + (-1)^2 a_2 + (-1)^3 a_3+\ldots\pmod 7$$
So, in fact, the alternating sum is congruent to the original number mod $7$.
A: $$N = \sum_{i=0} A_i 1000^i$$
$$D = \sum_{i=0} A_i (-1)^i$$
We want to prove $N \equiv 0 \pmod 7 \iff D \equiv 0 \pmod 7$, but you can prove the stronger statement:
$$N \equiv D \pmod {7}$$
by
$$\sum_{i=0} A_i 1000^i \equiv \sum_{i=0} A_i (-1)^i \pmod 7$$
and as noted by Rory Daulton in the comments, $1000 \equiv -1 \pmod 7$, so the above statement is true.
A: Let me unroll the process a little more for you. 
You have a number say that looks like $d_7d_6d_5d_4d_3d_2d_1$. We can rewrite this as  $d_7d_6d_5d_4 \times 1000 + d_3d_2d_1$. Then, because $1001=7\times 143$ we can rewrite the $1000$ as $7\times 143-1$, and the number as $d_7d_6d_5d_4 \times (7\times 143-1) + d_3d_2d_1 = d_7d_6d_5d_4 \times 7\times 143 - d_7d_6d_5d_4 + d_3d_2d_1$.
Now we're only interested in divisibility by 7, so we can ignore the part that is a multiple of seven and just test $ d_3d_2d_1 - d_7d_6d_5d_4 $. And now we can apply the same trick to the last part, and just test $ d_3d_2d_1 - (d_6d_5d_4 -d_7) = d_3d_2d_1 - d_6d_5d_4 + d_7$ - as required.
Note that $1001 =7\times 11\times 13$ so you can actually apply the same trick to test for divisibility by 13. For divisibility by 11 you can use a stronger version of the same technique, testing $ d_1 -d_2 + d_3-d_4 + d_5-d_6 + d_7$
