Divisibility by 7

Theorem
An integer $X$ with $n$ digits ($X_0$ in the ones place, $X_1$ in the tens place, and so on) is divisible by $7$ iff $\displaystyle \sum_{i \mathop = 0}^{n-1} \left({3^i X_i}\right)$ is divisible by $7$.

Proof
The first addend is always divisible by $7$ because $10^i - 3^i$ always produces a number divisible by $7$ from Difference of Two Powers.

So $X$ will be divisible by $7$ if and only if the second addend is divisible by $7$.