5. The sequence $\left\{a_{n}\right\}$ satisfies $a_{1}=2, a_{n+1}=(n+1) a_{n}-n$, then the general term formula of $\left\{a_{n}\right\}$ is $\qquad$
$$
a_{1}=2, a_{2}=3, a_{3}=7, a_{4}=25, a_{6}=121, a_{7}=721 \Rightarrow a_{n}=n!+1 .
$$

Assuming the conclusion holds for $n=k$, then for $n=k+1$, $a_{k+1}=(k+1) \cdot(k!+1)-k$ $=(k+1)!+k+1-k=(k+1)!+1$, which means the conclusion also holds for $n=k+1$. In summary, we have $a_{n}=n!+1\left(n \in \mathbf{N}^{*}\right)$.