Four, use $1,2,3,4,5$ to form all $n$-digit numbers where repetition is allowed, and the absolute difference between any two adjacent digits does not exceed 1. How many such numbers are there?
Let the number of $n$-digit numbers with the unit digit being 1 be $a_{n}$, the number of $n$-digit numbers with the unit digit being 2 be $b_{n}$, and the number of $n$-digit numbers with the unit digit being 3 be $c_{n}$. Then, the number of $n$-digit numbers with the unit digit being 4 is $b_{n}$, and the number of $n$-digit numbers with the unit digit being 5 is $a_{n}$. Clearly, $a_{1}=b_{1}=c_{1}=1$. Therefore,
$$
\begin{array}{l}
a_{n+1}=a_{n}+b_{n}, \\
b_{n+1}=a_{n}+b_{n}+c_{n}, \\
c_{n+1}=b_{n}+c_{n}+b_{n}.
\end{array}
$$

Thus,
$$
\begin{array}{l}
a_{n+1}+c_{n+1}+\sqrt{3} b_{n+1} \\
=(1+\sqrt{3})\left(a_{n}+c_{n}+\sqrt{3} b_{n}\right).
\end{array}
$$

Therefore,
$$
\begin{array}{l}
a_{n}+c_{n}+\sqrt{3} b_{n}=(1+\sqrt{3})^{n-1}(2+\sqrt{3}) \\
=\frac{1}{2}(1+\sqrt{3})^{n+1}.
\end{array}
$$

Similarly, $a_{n+1}+c_{n+1}-\sqrt{3} b_{n+1}$
$$
=(1-\sqrt{3})\left(a_{n}+c_{n}-\sqrt{3} b_{n}\right).
$$

Therefore, $a_{n}+c_{n}-\sqrt{3} b_{n}=\frac{1}{2}(1-\sqrt{3})^{n+1}$.
Adding (4) and (5) gives
$$
a_{n}+c_{n}=\frac{1}{4}\left[(1+\sqrt{3})^{n+1}+(1-\sqrt{3})^{n+1}\right].
$$
Subtracting (5) from (4) gives
$$
b_{n}=\frac{\sqrt{3}}{12}\left[(1+\sqrt{3})^{n+1}-(1-\sqrt{3})^{n+1}\right].
$$

From (1), we have $a_{n+1}-a_{n}=b_{n}$.
$$
\begin{array}{c}
\therefore \sum_{i=1}^{n}\left(a_{i+1}-a_{i}\right)=\sum_{i=1}^{n} b_{i}, \\
\quad a_{n+1}-a_{1} \\
\quad=\frac{\sqrt{3}}{12}\left[\sum_{i=1}^{n}(1+\sqrt{3})^{i+1}-\sum_{i=1}^{n}(1-\sqrt{3})^{i+1}\right] \\
=\frac{\sqrt{3}}{12}\left\{\frac{\left.(1+\sqrt{3})^{2}\left[(1+\sqrt{3})^{n}-1\right)-1-\sqrt{3}\right)^{2}\left((1-\sqrt{3})^{n}-1\right)}{(1-\sqrt{3})-1}\right\} \\
=\frac{1}{12}\left[(1+\sqrt{3})^{n+2}+(1-\sqrt{3})^{n+2}-8\right]. \\
\quad \therefore a_{n+1}=\frac{1}{12}(1+\sqrt{3})^{n+2}+\frac{1}{12}(1-\sqrt{3})^{n+2}+\frac{1}{3} \\
(n \geqslant 1), \\
\quad a_{n}=\frac{1}{12}(1+\sqrt{3})^{n+1}+\frac{1}{12}(1-\sqrt{3})^{n+1}+\frac{1}{3} \quad(n
\end{array}
$$
$>1$.
When $n=1$, $a_{n}=1$.
$\therefore$ When $n \geqslant 1$,
$$
\begin{array}{l}
a_{n}=\frac{1}{12}(1+\sqrt{3})^{n+1}+\frac{1}{12}(1-\sqrt{3})^{n+1}+\frac{1}{3}. \\
\therefore c_{n}=\frac{1}{6}(1+\sqrt{3})^{n+1}+\frac{1}{6}(1-\sqrt{3})^{n+1}-\frac{1}{3}.
\end{array}
$$

Therefore, the number of $n$-digit numbers is
$$
\begin{aligned}
a_{n} & +b_{n}+c_{n}+b_{n}+a_{n} \\
= & 2 a_{n}+2 b_{n}+c_{n} \\
= & \frac{1}{6}(1+\sqrt{3})^{n+1}+\frac{1}{6}(1-\sqrt{3})^{n+1}+\frac{2}{3} \\
& +\frac{\sqrt{3}}{6}(1+\sqrt{3})^{n+1}-\frac{\sqrt{3}}{6}(1-\sqrt{3})^{n+1} \\
& +\frac{1}{6}(1+\sqrt{3})^{n+1}+\frac{1}{6}(1-\sqrt{3})^{n+1}-\frac{1}{3} \\
= & \frac{1}{6}(2+\sqrt{3})(1+\sqrt{3})^{n+1}+\frac{1}{6}(2-\sqrt{3})(1- \\
& \sqrt{3})^{n+1}+\frac{1}{3}. \\
= & \frac{1}{12}(1+\sqrt{3})^{n+3}+\frac{1}{12}(1-\sqrt{3})^{n+3}+\frac{1}{3}.
\end{aligned}
$$