Example 2: Using $1,2,3,4,$ and $5$, how many $n$-digit numbers can be formed where each pair of adjacent digits differ by exactly 1?

 untranslated text:
例 2 用 $1,2,3,4 、 5$ 可以构成多少个各相邻数字恰好相差 1 的 $n$ 位数? 

translated text:
Example 2: Using $1,2,3,4,$ and $5$, how many $n$-digit numbers can be formed where each pair of adjacent digits differ by exactly 1?
Let the number of numbers that satisfy the condition be $a_{n}$.
Let the numbers that start with $1,2,3,4,5$ and satisfy the condition be $y_{n}, z_{n}, u_{n}, v_{n}, w_{n}$ respectively. Then,
$$
a_{n}=y_{n}+z_{n}+u_{n}+v_{n}+w_{n},
$$

and $y_{n}=w_{n}, z_{n}=v_{n}$.
When starting with $1$ or $2$, we have $y_{n}=z_{n-1}$;
When starting with $2,1$ and $2,3$, we have
$$
z_{n}=y_{n-1}+u_{n-1} ;
$$

When starting with $3,2$ or $3,4$, we have $u_{n}=2 z_{n-1}$.
Thus, $z_{n}=3 z_{n-2}$, and $z_{1}=1, z_{2}=2$.
Therefore, $z_{2 n}=3 z_{2 n-2}=3^{2} z_{2 n-4}=\cdots$
$$
=3^{n-1} z_{2}=2 \times 3^{n-1} \text {, }
$$
$$
z_{2 n-1}=3 z_{2 n-3}=\cdots=3^{n-1} z_{1}=3^{n-1} \text {. }
$$

And $a_{n}=2 z_{n}+4 z_{n-1}$, so
$$
a_{2 n}=2\left(2 \times 3^{n-1}\right)+4 \times 3^{n-1}=8 \times 3^{n-1},
$$

and $a_{2 n+1}=2 \times 3^{n}+4\left(2 \times 3^{n-1}\right)=14 \times 3^{n-1}$.