Just to provide a concrete underpinning to this general reasoning: $$\sum_{n=0}^{\infty}\frac{1}{n!}x^n=e^x$$ Differentiate and then multiply by $x$: $$\sum_{n=0}^{\infty}\frac{n}{n!}x^n=xe^x$$ Differentiate and then multiply by $x$: $$\sum_{n=0}^{\infty}\frac{n^2}{n!}x^n=x(x+1)e^x$$ Adding the first and last equations: $$\sum_{n=0}^{\infty}\frac{n^2+1}{n!}x^n=(x^2+x+1)e^x$$ So the value of your sum is $3e$.