6. Given the sequence $\left\{a_{n}\right\}$ satisfies $a_{1}=1, a_{2}=4, a_{3}=10$, for any $n \geqslant 2$ there is $a_{n+1}^{2}-2 a_{n}^{2}=$ $a_{n} a_{n+2}-2 a_{n-1} a_{n+1}$, then the unit digit of $a_{21}$ is $\qquad$.
Solve
$a_{n+1}^{2}+2 a_{n-1} a_{n+1}=a_{n} a_{n+2}+2 a_{n}^{2} \Rightarrow \frac{a_{n+2}+2 a_{n}}{a_{n+1}}=\frac{a_{n+1}+2 a_{n-1}}{a_{n}}=\cdots=\frac{a_{3}+2 a_{1}}{a_{2}}$ $=3 \Rightarrow a_{n+2}=3 a_{n+1}-2 a_{n}$, the characteristic equation is $x^{2}-3 x+2=0 \Rightarrow x=1$ or 2, so $a_{n}=c_{1}+c_{2} \cdot 2^{n} \Rightarrow\left\{\begin{array}{l}c_{1}+2 c_{2}=1, \\ c_{1}+4 c_{2}=4\end{array} \Rightarrow\left\{\begin{array}{l}c_{1}=-2, \\ c_{2}=\frac{3}{2}\end{array} \Rightarrow a_{n}=3 \cdot 2^{n-1}-2\right.\right.$. Therefore, $a_{21}=3 \cdot 2^{20}-2=3 \cdot(1024)^{2}-2 \equiv 3 \cdot 4^{2}-2 \equiv 6(\bmod 10)$.