2

Consider sequnece constructed in a such way: $a_1 = 2, a_2 = 0, a_3 = 2, a_4 = 3$ and $a_n = (a_{n-1} + a_{n-2} + a_{n-3} + a_{n-4}) \mod 10$.

The question is whether 2, 0, 2, 3 in a row will ever repeat.

Using Chinese remainder theorem we can consider sequnce $(b_n, c_n) \in \mathbb{Z}_2 \oplus \mathbb{Z}_5$, where $b_n = (a_n \mod 2)$, $c_n = (a_n \mod 5)$. This sequence cycles on its first component: $0, 0, 0, 1, 1, 0, 0, 0, 1, 1...$ but can't do anything with $c_n$.

I know, that the answer is true(computer program) and first time it repeat in $a_{1561}$.

So I'm interested in the 'human' solution.

Bill Dubuque
  • 272,048
Val
  • 63
  • 2
    That it repeats follows from general principles as explained here i.e. the shift map $$\begin{align}&(a_n,a_{n+1},a_{n+2},a_{n+3})\ \to \ \ &(a_{n+1},a_{n+2},a_{n+3},a_{n+3}+a_{n+2}+a_{n+1}+a_n)\end{align}\qquad$$ is an invertible map on a finite set $,\Bbb Z_{10}^4$ so it is a permutation so its orbits are cycles, so the initial value $(a_1,a_2,a_3,a_4)$ repeats infinitely many times in its cycle. Don't reinvent the wheel (cycle)! – Bill Dubuque May 14 '23 at 17:14

2 Answers2

3

There is a very different way of looking at this problem which casts further light on what is happening. One can consider the transformation of four successive values $a,b,c,d$ into the 'next' four values $b,c,d,a+b+c+d$ as a matrix transformation:- $$\begin{pmatrix}0&1&0&0 \\0&0&1&0 \\0&0&0&1 \\1&1&1&1 \end{pmatrix} \begin{pmatrix}a \\b \\c \\d\end{pmatrix}= \begin{pmatrix}b \\c \\d \\a+b+c+d\end{pmatrix}$$ This transformation matrix, $M$ say, is a companion matrix (see for example https://en.wikipedia.org/wiki/Companion_matrix) and so, without calculating, we know it satisfies the equation $$M^4-M^3-M^2-M-I=0.$$

I'll give a couple of examples of what we can deduce from this way of looking at the problem:-

MODULO $2$

We have $$M^5-I=(M^4-M^3-M^2-M-I)(M-I)=0.$$ and therefore $M^5$ is the identity element. Thus a sequence starting with any four initial values (and not just $2,0,2,3$) will recur after five iterations.

WHY SEQUENCES HAVE TO REPEAT

There are only a finite number of matrices over a finite field and so the sequence $I, M, M^2, M^3, M^4, ... $ must contain repetitions. Suppose $M^v=M^u, v>u$.

Since $M$ is invertible we can multiply by a power of its inverse to give $M^{v-u}=I $. As we have seen in the modulo 2 case this means that any sequence has to recur after $v-u$ iterations. (Some might recur after some factor of $v-u$ iterations.)

user1172706
  • 1,405
2

@Bill Dubuque beat me to the most important point that it is bound to repeat.

Your observation re. the primes $2$ and $5$ is also useful. You have seen that mod $2$ it forms a cycle of period $5$. So you are looking for a 'human proof' that mod $5$ it forms a cycle of period $312$ because then the actual period will be the product of the coprime numbers $5$ and $312$ i.e. $1560$.

The 'easiest' thing I've noted is that after $78$ goes, a pattern $a,b,c,d$ becomes $3a,3b,3c,3d$ and so (since $3^4$ is $1$ mod $5$) the cycle has length the product of $4$ and $78$ i.e $312$ as required.

So, to understand what is going on, only $78$ iterations are needed rather than $1560$.

user1172706
  • 1,405