TITLE: Divisibility by 7 rule, and Congruence Arithmetic Laws
QUESTION [98 upvotes]: I have seen other criteria for divisibility by 7. Criterion described below present in the book Handbook of Mathematics for IN Bronshtein (p. 323) is interesting, but could not prove it.
Let $n = (a_ka_{k-1}\ldots a_2a_1a_0)_{10} = \displaystyle{\sum_{j=0}^{k}}a_{k-j}10^{k-j}$. The expression
$$
Q_{3}^{\prime}(n) = (a_2a_1a_0)_{10} - (a_5a_4a_3)_{10} + (a_8a_7a_6)_{10} -\ldots 
$$
are called alternating sum of the digits of third order of $n$. For example, 
$$
Q_{3}^{\prime}(123456789) = 789-456+123=456
$$
Proposition: $7 | n \ \Leftrightarrow \ 7 | Q_{3}^{\prime}(n)$.
proof. ??
Thanks for any help.

REPLY [5 votes]: Note that $1001$ is divisible by $7$, hence, $ 1000 \equiv -1 (\bmod 7) $.
Let, $n = a_0 + 10^1a_1+\ldots +10^ka_k$. 
Partition $(a_0,\ldots,a_k)$ into groups of three to get
$$n=\sum_{i=0}10^{3i}(a_i+10^1a_{i+1}+10^2a_{i+2})\equiv\sum_{i=0}(-1)^{i}(a_i+10^1a_{i + 1}+10^2a_{i + 2}) (\bmod 7)$$
And that is exactly what we were trying to prove.