I have a sequence defined as follows $$u_1=2, \quad u_{n+1}=nu_n+2.$$
And I want to compute (if possible) the explicit solution.
I have a sequence defined as follows $$u_1=2, \quad u_{n+1}=nu_n+2.$$
And I want to compute (if possible) the explicit solution.
This is very particular case of a general difference equation of order one of the form $$ u_{n+1}=p_{n}u_{n}+q_{n}, $$ where $(p_{n}), (q_{n})$ are given sequences. The solution is given by: $$ u_{n}=\left(\prod_{i=1}^{n-1}p_{i}\right)u_{1}+\sum_{i=1}^{n-1}\left(\prod_{j=i+1}^{n-1}p_{j}\right)q_{i} $$ In your case $p_{n}=n, q_{n}=2$, and after necessary simplifications, one can easily get $$ u_{n}=2\sum_{j=0}^{n-1}\frac{(n-1)!}{j!}. $$