Expressing a recursively defined function in terms of factorials or gamma function Given the recursion
$$f(n) = nf(n-1) + (n-1)f(n-2) $$
$$f(0) = 1, f(1) = 1$$
How exactly does one express the target function?

I know that
$$f(n) = nf(n-1)$$
gives rise to
$$f(n) = \Gamma(n+1)$$
By repeatedly substituting I can then derive
$$f(n) = \Gamma(n+1) + (n-1)f(n-2) + n(n-2)f(n-3) + n(n-1)(n-3)f(n-4) ... $$
Where to go from there?
 A: You can consider the similar and well known recursion $!n=(n-1)[!(n-1)+!(n-2)]$, where $!k$ denotes the subfactorial of $k$. The sequence starts with $!1=0$ and $!2=1$, and continues according to the recursion with $!3=2$, $!4=9$, and so on. The subfactorial of $k$  expresses the number of permutations of $k$ objects in which no object appears in its "natural place" (i.e., for integers, the position after they have been ordered).
Calling $f(x)$ the recursive formula described in the question, we have $f(1)=1$ and $f(2)=3$. We then can note that $f(1)=\displaystyle \frac{!3}{2}$ and $f(2)=\displaystyle \frac{!4}{3}$. 
If now we want to calculate $f(3)$, we can write $$f(3)= 3\cdot f(2)+2\cdot f(1)= 3\cdot \displaystyle \frac{!4}{3} +  2 \cdot \displaystyle \frac{!3}{2}=!4\,+ \,!3$$
and noting that $!4\, + \,!3=\displaystyle \frac{!5}{4}$ we get
$$ f(3)=\displaystyle \frac{!5}{4}$$
Therefore, the relationships $ f(1)=\displaystyle \frac{!3}{2}$ and  $ f(2)=\displaystyle \frac{!4}{3}$ continue with $ f(3)=\displaystyle \frac{!5}{4}$. Iterating the process, we obtain that $ f(4)=\displaystyle \frac{!6}{5}$, $ f(5)=\displaystyle \frac{!7}{6}$, and so on. Generalizing, we have that
$$ f(n)=\displaystyle \frac{!(n+2)}{(n+1)}$$
Since the subfactorial is linked to the incomplete gamma function by the relationship $!k=\displaystyle \frac{\Gamma(k+1, -1)}{e}$, we can conclude that 
$$f(n)=\displaystyle \frac{\Gamma(n+3, -1)}{e\cdot(n+1)}$$
Accordingly, the last formula yields for $n=1,2,3,4,5....$ the values $1,3,11,53,309....$, which correspond to those obtained by the recursion described in the OP. Also note that the formula works for $n=0$ as well, since it yields $1$.
