Each term in a sequence $1, 0, 1, 0, 1, 0, . . .$ starting with the seventh is the sum of the last $6$ terms $\mod 10$. Prove that the sequence $. . . , 0, 1, 0, 1, 0, 1, . . .$ never occurs.
Why $I(x_1, x_2, . . . , x_6) = 2x_1 + 4x_2 + 6x_3 + 8x_4 + 10x_5 + 12x_6 \mod 10$ is the invariant?
$$x_7\equiv x_1+x_2\dots x_6\mod10$$ $$\begin{align}2x_2+4x_3+6x_4+8x_5+10x_6+12x_7\equiv&2x_2+4x_3+6x_4+8x_5\\&+10x_6+12(x_1+x_2\dots x_6)\\\equiv&12x_1+14x_2+16x_3+18x_4+20x_5+22x_6\\ \equiv&2x_1+4x_2+6x_3+8x_4+10x_5+12x_6\end{align}$$
I dont have any motivation for this though. Maybe because of how $x_7$ is defined this is chosen