Divisibility by 7. Let $b = a_5a_4a_3a_2a_1a_0$ integer that has a maximum of six digits. 
Here we have: if $b$ is a five-digit number, then $a_5 = 0$; if $b$ is a four-digit number , then $a_5$, $a_4 = 0$, and so on. Prove that


*

*$$ b \equiv a_0 - a_3 + 3 (a_1 - a_4) + 2 (a_2 - a_5) \pmod 7 $$

*$$ 10^6 \equiv 1 \pmod 7$$


From this derive the criterion of divisibility of an integer number $7$.
Can anyone help me with this?
I know that to determine if a number is divisible by $7$, take the last digit off the number, double it and subtract the doubled number from the remaining number. If the result is evenly divisible by $7$ (e.g. $14, 7, 0, -7$, etc.), then the number is divisible by seven.
 A: Rewrite $b$ as 
$$a_0 + 10^1a_1 + 10^2 a_2+ \dots+ 10^5 a^5$$
If you worked out $10^0, 10^1, 10^2, \dots, 10^5 \pmod 7$ for $a_0,a_1,\dots,a_5$ respectively, you'll get exactly the required coefficients.

The $10^6 \equiv 1 \pmod 7$ is there to indicate that the coefficients will repeat after every $6$ terms.
A: As $10^3\equiv-1\pmod7$
$$\sum_{r=0}^{3n-1}(10^{3r}a_{3r}+10^{3r+1}a_{3r+1}+10^{3r+2}a_{3r+2})\equiv\sum_{r=0}^{3n-1}(-1)^ra_{3r}a_{3r+1}a_{3r+2}\pmod7$$

OR
As $7\cdot3-10\cdot2=1,$
Use the reduction formula : 
$$21x-2(10x+y)\equiv x-2y\pmod7$$ for $10x+y$ recursively
A: Note that $1001=7\times 11 \times 13$ so subtracting $1001 \times (100a_6+10a_5+a_4)$ gives $100(a_2-a_5)+10(a_1-a_4)+(a_0-a_3)$ divisible by $7$.
Now we note that $98$ and $7$ are divisible by $7$ to reduce to $2(a_2-a_5)+3(a_1-a_4)+(a_0-a_3)$ as differing from the original number by a multiple of $7$.
Others have written n more technical ways. This is how I would approach the problem in practice - not needing to remember a formula, but having a working method to hand. A formula is handy for a computer or a calculator.
