Show that $\sum\limits_{i=0}^n \frac{(-1)^i}{i!}(n-i)^ie^{n-i}=2n+\frac23+o(1)$ When modeling the average queue length of an M/D/1/K queue, we encountered the expression $$A_n=\sum_{i=0}^n \frac{(-1)^i}{i!}(n-i)^ie^{n-i}$$
Empirically, $$A_n\approx2n + \frac{2}{3}$$ for large $n$, and at least for $n > 5$. For instance, $$A_6=12.66666714138\qquad A_{10}=20.66666666648$$
These values are too neat to be a mere coincidence, but we are not able to explain them.
Mathematically, the result to be proven is
$$\lim_{n\to\infty}\ (A_n-2n)=\frac23$$ that is, $$\lim_{n\to\infty} \left( \sum_{i=0}^n \frac{(-1)^i}{i!}(n-i)^ie^{n-i} - 2n\right) = \frac{2}{3}$$ 
Any pointers on how to prove this would be greatly appreciated.
 A: It seems natural to try the generating function approach, i.e. to calculate $g(x)=\sum_{n\ge 0}A_n\,x^n$.
$$
    g(x)=\sum\limits_{n=0}^\infty\left(\sum_{i=0}^n\frac{(-1)^i}{i!}\,(n-i)^i\,e^{n-i}\right)\,x^n=
 \sum\limits_{i,k\ge 0}\frac{(-1)^i}{i!}\,k^i\,e^k\,x^{i+k}=\sum\limits_{k\ge 0}e^k\,x^k\,e^{-kx}=
 \frac{1}{1-x\,e^{1-x}},
$$
with the substitution $k=n-i$. Changing the order of summation is justified, since the double series is absolutely convergent in a neighborhood of zero.
To get the asymptotics, we expand the generating function in a neighborhood of 1. Maxima says
$$
g(x)={{2}\over{(1-x)^2}}-{{4}\over{3\,(1-x)}}+{{7}\over{18}}-{{8\,(1-x)}\over{135}}+
 {{11\,(1-x)^2}\over{3240}}+\ldots
$$
So clearly, $A_n=2(n+1)-4/3+o(1)=2n+2/3+o(1)$. The error term is dominated by the next pole of $g(z)$, i.e. the closest to $z=0$, but different from $z=0$ zero of 
$(1-z)\,e^z-1$. It has to be complex, that explains the oscillating behavior of the error.
EDIT: Numerical computation seems to indicate that this zero is $z_0=-2.088843015613044+7.461489285654254j$ (and its complex conjugate, of course).
That would mean $\log|z_0|=2.0474812481624842$, in rough agreement with the numerical results of Claude Leibovici.
