<s>[INST] Is there any general formula for $S = 1^1 + 2^2 + 3^3 + \dotsb+(n - 1)^{n - 1} + n^n, n \in N$? Is there any general formula to sum following series:
$$S = 1^1 + 2^2 + 3^3 + \dotsb+(n - 1)^{n - 1} + n^n, n \in N$$
I mean for $S = f(n)$, is there a formula to compute $f(n)$?
 [/INST] I don't know if a closed form exists, but an asymptotic approximation can be given as
$$
\begin{align}
&n^n\left(1+\frac1n\frac{(n-1)^{n-1}}{n^{n-1}}+\frac1{n^2}\frac{(n-2)^{n-2}}{n^{n-2}}+\frac1{n^3}\frac{(n-3)^{n-3}}{n^{n-3}}+O\left(\frac1{n^4}\right)\right)\\
&=\bbox[5px,border:2px solid #C0A000]{n^n\left(1+\frac1{en}+\frac{3+e}{2e^2n^2}+\frac{52+60e+7e^2}{24e^3n^3}+O\left(\frac1{n^4}\right)\right)}
\end{align}
$$
where
$$
\begin{align}
\log\left(\frac{(n-k)^{n-k}}{n^{n-k}}\right)
&=(n-k)\left(-\frac kn-\frac{k^2}{2n^2}-\frac{k^3}{3n^3}+O\left(\frac1{n^4}\right)\right)\\
&=-k+\frac{k^2}{2n}+\frac{k^3}{6n^2}+O\left(\frac1{n^3}\right)
\end{align}
$$
and so
$$
\frac1{n^k}\frac{(n-k)^{n-k}}{n^{n-k}}
=e^{-k}\left(\frac1{n^k}+\frac{k^2}{2n^{k+1}}+\frac{3k^4+4k^3}{24n^{k+2}}+O\left(\frac1{n^{k+3}}\right)\right)
$$
</s>