Periodic tribonacci-like sequence How to prove that if $a_n =[(t_{n-3} + 2t_{n-2} + t_{n-1}) a_{1} + (t_{n-3} + t_{n-2} + 2t_{n-1})] \quad (\text{mod}10)$ and $a_{1}, a_{2}, a_{3}$ are consecutive numbers and $t_{1}=0, t_{2}=1$ and $t_{3}=1$ are the first three terms of a tribonacci sequence, then $a_{n} = a_{n+62}$?
 A: The period of $t_n\bmod 5$ is 31. $t_n\bmod 2$ repeats the sequence 0, 0, 1, 1. From this, it is not hard to see that $t_{n+62}=t_n+5$, modulo 10.
The question's formula for $a_n$ contains two parenthesised expressions, each of which remains unchanged (modulo 10) if $n$ is increased by 62 and thus each of the $t$'s is changed by 5. Thus $a_n=a_{n+62}$.
Could the period of $t_n\bmod 5$ be found more easily than by calculating 31 further terms? The tribonacci recurrence is $t_n=t_{n-1}+t_{n-2}+t_{n-3}$. The corresponding characteristic cubic is thus $x^3-x^2-x-1$, and its discriminant is $-44=-4\cdot11$. $5$ is a prime; moreover, modulo $11$, 5 is a square ($5=16=4^2$), so some primitive binary quadratic form of discriminant $-44$ represents 5 [1]. Unfortunately, $h(-44)=3$, that is, there are $3$ equivalence classes of primitive binary quadratic forms of discriminant $-44$. We need to know which one represents 5.
Here follows a more general principle for finding information about the period $R$ of a cubic recurrence modulo a prime $p$, where the recurrence's characteristic cubic's discriminant is $D$, and $h(D)=3$.
If the principal binary quadratic form of discriminant $D$ represents $p$, and $p\nmid D$, then $R\mid p-1$.
If the other primitive binary quadratic form of discriminant $D$ represents $p$, then $R\mid p^2+p+1$. Note that $p^2+p+1=(p^3-1)/(p-1)$.
If $p$ is not a square modulo $D$ (if $D$ is odd) or $D/4$ (if $D$ is even), then $R\mid p^2-1$.
Back to the case in question. The principal binary quadratic form of discriminant $-44$ is $x^2+11y^2$, which does not represent 5. The other one is $g(x, y)=3x^2+2xy+4y^2$, and $g(1, -1)=5$. So the period divides $p^2+p+1$ which here is 31. Which is prime, and the period can't be 1, so it must be 31, as required.

[1] This inference applies only to representation of primes. Like 5, 38 and 82 are congruent to $16=4^2$ modulo 11, but no binary quadratic form of discriminant $-44$ represents 38 or 82. Not even the non-primitive $2x^2+2xy+6y^2$.
