Let's assume we want to find a divisibility criterion for $7$ of a given a number $N$
\begin{align*}
N=a_{n}\cdot 10^n + a_{n-1} \cdot 10^ {n-1} + \cdots + a_3\cdot 10^3 + a_2\cdot 10^2 + a_1\cdot 10 + a_0
\end{align*}
based upon the digits $a_0,a_1,a_2,\ldots,a_n$ of $N$.
In order to do so we apply the modular arithmetic to consecutive powers of $10$ until we find a smallest exponent $n\geq 1$ with $10^{n}\equiv 1 \pmod{7}$.
We obtain
\begin{align*}
10&\equiv 3 \pmod{7}\\
100&\equiv 10\cdot 10\equiv 3\cdot 3\equiv 2 \pmod{7}\\
1000&\equiv 10\cdot 100\equiv 3\cdot2\equiv -1 \pmod{7}\tag{1}\\
10000&\equiv 100\cdot 100\equiv 2\cdot 2\equiv -3 \pmod{7}\\
100000&\equiv 100\cdot 1000\equiv 2\cdot (-1)\equiv -2 \pmod{7}\\
1000000&\equiv 1000\cdot 1000\equiv (-1)\cdot (-1)\equiv 1 \pmod{7}\tag{2}
\end{align*}
Comment:
In the last line (2) we obtain a power of $10$ which is congruent $1$ modulo $7$. So, the next power of ten is $10000000 \equiv 10\equiv 3 (\pmod{7})$ and we continue cyclically with the first line.
In (1) we reduce $1000$ to $-1$ and not to the smallest positive value $6$. This way we will find a smaller number than $n$ with the same residue modulo $7$ somewhat easier.
We can now formulate a divisibility criterion based upon the digits of the number $N$:
The following divisibility criterion for $7$ of a given number $N$ is valid
\begin{align*}
N&=a_{n}\cdot 10^n + a_{n-1} \cdot 10^ {n-1} + ... + a_3\cdot 10^3 + a_2\cdot 10^2 + a_1\cdot 10 + a_0\\
&\equiv a_0+3a_1+2a_2-a_3-3a_4-2a_5\\
&\qquad +a_6+3a_7+2a_8-a_{9}-3a_{10}-2a_{11}\\
&\qquad +\cdots \pmod{7}
\end{align*}
For convenience only we started the last expression with $a_0$ and stopped with $\cdots$.
Note the repeating sequence $1,3,2,-1,-3,-2$.
Let's look how to apply this rule. Also note that we can apply the rule more than once, to iterativeley reduce the number under test.
Example: Check the divisibility of $N=8732576$ with respect to the modulus $7$.
\begin{align*}
N&=8732576=8\cdot 10^6+7\cdot 10^5+3\cdot 10^4+2\cdot 10^2+5\cdot 10^2+7\cdot 10^1+6\cdot 10^0\\
&\equiv 6+3\cdot 7+2\cdot 5-2-3\cdot 3-2\cdot 7+8=20\tag{3}\\
&\equiv 2\cdot 10^1+0\cdot 10^0\\
&\equiv 0+3\cdot 2=6 \pmod{7}
\end{align*}
We conclude: $n=8732576$ is not divisible by $7$, since the division gives a remainder $6$.
Comment:
- In (3) we apply the divisibility criterion again to $20$. So, we get a chain $N=8732576\rightarrow 20\rightarrow 6$ until we find a non-negative value less than the modulus $7$.