<s>[INST] Providing a closed formula for a linear recursive sequence I am studying for an exam in linear algebra and I have some trouble solving the following:
Let $(a_n)$ be a linear recursive sequence in $\mathbb{Z}_5$ with
\begin{align} 
a_0 = 2, a_1 = 1, a_2 = 0 \text{ and } a_{n+3} = 2a_{n+2} + a_{n+1} + 3a_n \text{ for }  n \in \mathbb{N}_0
\end{align}  
Provide a closed formula for $a_n$.
My findings so far:
$
\begin{pmatrix} a_{n+3}  \\ a_{n+2} \\ a_{n+1} \\ \end{pmatrix}
   = \begin{pmatrix} 2 & 1 & 3  \\1 & 0 & 0  \\ 0 & 1 & 0 \\ \end{pmatrix} \cdot \begin{pmatrix} a_{n+2}  \\ a_{n+1} \\ a_{n} \\ \end{pmatrix} 
$
$
\begin{pmatrix} a_{n}  \\ a_{n+1} \\ a_{n+2} \\ \end{pmatrix}
   = A^n \cdot \begin{pmatrix} a_{0}  \\ a_{1} \\ a_{2} \\ \end{pmatrix} = A^n \cdot \begin{pmatrix} 2  \\ 1 \\ 0 \\ \end{pmatrix} 
$
At some point there must hold the following:
\begin{align} 
T^{-1}AT = D = \begin{pmatrix} c_1 & 0 & 0  \\0 & c_2 & 0  \\ 0 & 0 & c_3 \\ \end{pmatrix}
\end{align} 
such that D is a diagonal matrix containing all Eigenwerte $c_i$, $i \in {\{1,2,3} \}$  of $A$.
How shall I continue to find the matrix $A$?
 [/INST] Hint: Use elementary row operations on your matrix $A$. You shall get identity matrix as $D$. Represent $T$ by elementary matrixes
</s>