5. Find the number of such sequences: of length $n$, each term is 0, 1, or 2, and 0 is neither the predecessor nor the successor of 2.
5. Let in the said sequence, there are $a_{n}$ ending with 0, $b_{n}$ ending with 1, and $c_{n}$ ending with 2, then $a_{1}=b_{1}=$ $c_{1}=1$. And there are the recurrence relations $a_{n+1}=a_{n}+b_{n}, b_{n+1}=a_{n}+b_{n}+c_{n}, c_{n+1}=b_{n}+c_{n}$. Thus, $a_{n+1}+c_{n+1}+\sqrt{2} b_{n+1}=1+$ $\sqrt{2}\left(a_{n}+c_{n}+\sqrt{2} b_{n}\right)$, hence $a_{n}+c_{n}+\sqrt{2} b_{n}=(1+\sqrt{2})^{n-1}\left(a_{1}+c_{1}+\sqrt{2} b_{1}\right)=(1+\sqrt{2})^{n-1}(2+\sqrt{2})=\sqrt{2}(1+\sqrt{2})^{n}$, taking the conjugate gives $a_{n}+c_{n}-\sqrt{2} b_{n}=-\sqrt{2}(1-\sqrt{2})^{n}$. Therefore, $a_{n}+c_{n}=\frac{\sqrt{2}}{2}\left[(1+\sqrt{2})^{n}-(1-\sqrt{2})^{n}\right], b_{n}=\frac{1}{2}\left[(1+\sqrt{2})^{n}\right.$ $\left.+(1-\sqrt{2})^{n}\right]$. Hence, $a_{n}+b_{n}+c_{n}=\frac{1}{2}\left[(1+\sqrt{2})^{n+1}+(1-\sqrt{2})^{n+1}\right]$. This is the result we are looking for.