Starting with $1,9,9,3$ the sequence continues as the last digit of the sum of preceding 4 terms. Will subsequence $7, 3, 6, 7$ ever appear in it?

Here's what I did first : if $7,3,6,7$ appeared in the sequence, then continuing the sequence is revealing.

Indeed, we get : $$ 7,3,6,7,3,9,5,4,\color{blue}{1,9,9,3},... $$

therefore, the sequence $7,3,6,7$ appears, if and only if $1,9,9,3$ appears again.


Consider the operation $T :(a,b,c,d) \to (b,c,d,a+b+c+d)$ as a linear transformation from $\mathbb Z_{10}$ to $\mathbb Z_{10}$. We basically have to debate if $T^n(1,9,9,3) = (1,9,9,3)$ for some $n$. It is sufficient to show that $T^n$ is the identity map for some $n$.

For this, note that it is enough to show that $T^n$ is the identity map modulo $2$ and $T^m$ is the identity map modulo $5$ for some $n,m$. Then the lcm of $n,m$ provides a candidate power $T^N$ being the identity modulo $10$.

We can use the field polynomial theory at this point. Indeed, note that we have the following : $$ x^{p^n} - x = \prod_{d | n} \textrm{ (all monic irreducible polynomials in $\mathbb F_p[x]$ of degree $d$)} $$

as polynomials in $\mathbb F_p[x]$ fo any prime $p$ and for any $n$.

Therefore, suppose that the characteristic polynomial of $T$ is irreducible modulo $2$ and modulo $5$. From this formula (substituting the matrix $T$ in place of the variable $x$) it follows that $T^{2^4} = T$ modulo $2$ and $T^{5^4} = T$ modulo $5$ (since the characteristic polynomial is monic of degree $4$), and because $T$ is invertible (check!) we get that $T^{15} = I$ modulo $2$ and $T^{624} = I$ modulo $5$.

It is irreducible modulo $2$ and $5$! Indeed, the characteristic polynomial is $t^4-t^3-t^2-t-1$ , and one can use a standard table of quadratic irreducible polynomials modulo $2$ to verify for $p=2$ and $p=5$ to show that it doesn't have quadratic factors, and simple substitution show no linear factors.

In particular, we must have $T^{3120} = I$ modulo $10$. It follows that $7,3,6,7$ appear in the sequence. You can even find at least one place where they appear.


So we saw :

  • Working from the sequence $7,3,6,7$ brought the question down to whether the transformation itself was, if raised to a certain power the identity.

  • We expressed it as a linear transformations modulo a number, and then modulo a prime , and we looked at its characteristic polynomial modulo these primes.

  • A nice irreducible polynomial formula was used, which helped us show that the period in fact exists.


EDIT : As Greg points out below, we can make a simpler argument for the recurrence of $(1,9,9,3)$ using backward recursion.

Consider the $10^4+1$ triplets $(a_{n},a_{n+1},a_{n+2},a_{n+3}) , n = 1,2,...,10001$. Two of these must be the same, by the pigeonhole principle. This shows that there exist $T^n(1,9,9,3) = T^m(1,9,9,3)$ for some $n \neq m$. By backward recursion (same as saying that $T$ is invertible), we get that $T^{|n-m|}(1,9,9,3) = (1,9,9,3)$, which shows that $1,9,9,3$ appears again.

Of course, note that this does not provide us with an explicit point at which the sequence $7,3,6,7$ appears, which the other method provides. So you can contrast these methods.


If $X_n = \pmatrix{a_n\cr a_{n+1}\cr a_{n+2}\cr a_{n+3}\cr}$, we have $X_{n+1} = M X_n \mod 10$ where $M = \pmatrix{0 & 1 & 0 & 0\cr 0 & 0 & 1 & 0\cr 0 & 0 & 0 & 1\cr 1 & 1 & 1 & 1\cr}$. That matrix has characteristic polynomial $P(\lambda) = \lambda^4 - \lambda^3 - \lambda^2 - \lambda - 1$, which is irreducible both mod $2$ and mod $5$. The period of $M$ mod $p$ must be a divisor of $p^4-1$. We find the period mod $2$ is $5$ and the period mod $5$ is $312$. Therefore the period mod $10$ is $5 \cdot 312 = 1560$.

With $X_0 = \pmatrix{1\cr 9\cr 9\cr 3\cr}$ I find $X_{1552} = \pmatrix{7\cr 3\cr 6\cr 7\cr}$.