$\int_{0}^{\infty} \lfloor ne^{-x} \rfloor \mathrm{d}x$ where $n\in \mathbb{N} $ and $x\in \mathbb{R} ^{+} $ Find
$\int_{0}^{\infty} \lfloor ne^{-x} \rfloor \mathrm{d}x$  where $n\in \mathbb{N} $ and $x\in \mathbb{R} ^{+} $
I started thinking like this -
$f(x) =ne^{-x} $. So, $f'(x) =-ne^{-x} < 0$
So $f$  is decreasing in $0$ to $\infty$. Now let us break the interval for $x>\ln n$ then $e^x>n$ so $ne^{-x} <1$.So,we have $\lfloor ne^{-x} \rfloor =0$ for $x>\ln n$
So the integral becomes
$\int_{0}^{\infty}\lfloor ne^{-x}\rfloor \mathrm{d}x =\int_{0}^{\ln n} \lfloor ne^{-x} \rfloor \mathrm{d}x +\int_{\ln n} ^{\infty} \lfloor ne^{-x} \rfloor \mathrm{d}x$ .
The second part is zero. But how to tackle $\int_{0}^{\ln n} \lfloor ne^{-x} \rfloor \mathrm{d}x$
Can I carry on from here? If there is any independent way,that is also welcome. Thanks in advance.
 A: You have already found
$$ I_n \equiv \int \limits_0^\infty \lfloor n \mathrm{e}^{-x} \rfloor \, \mathrm{d} x = \int \limits_0^{\ln(n)} \lfloor n \mathrm{e}^{-x} \rfloor \, \mathrm{d} x $$
for $n \in \mathbb{N}$. The integrand decreases in steps and changes its value whenever $n \mathrm{e}^{-x}$ is an integer. More precisely, for $m \in \{1, \dots, n-1\}$ we have $\lfloor n \mathrm{e}^{-x}\rfloor = m \, \Leftrightarrow \ln \left(\frac{n}{m+1}\right) < x \leq \ln \left(\frac{n}{m}\right)$. Following blamethelag's suggestion we write
$$ [0, \ln(n)] = \{0\} \cup \bigcup_{m=1}^{n-1} \left(\ln\left(\frac{n}{m+1}\right), \ln \left(\frac{n}{m}\right)\right] \, .$$
The integrand is equal to $m$ on the $m$-th half-open interval. Its value $n$ on $\{0\}$ does not matter for the integral, since it is only assumed at a single point. Therefore, we obtain
\begin{align}
I_n &= \sum \limits_{m=1}^{n-1} \int \limits_{\ln\left(\frac{n}{m+1}\right)}^{\ln\left(\frac{n}{m}\right)} \lfloor n \mathrm{e}^{-x} \rfloor \, \mathrm{d} x = \sum \limits_{m=1}^{n-1} \int \limits_{\ln\left(\frac{n}{m+1}\right)}^{\ln\left(\frac{n}{m}\right)} m \, \mathrm{d} x = \sum \limits_{m=1}^{n-1} m \left[\ln\left(\frac{n}{m}\right) - \ln\left(\frac{n}{m+1}\right)\right] \\
&= \sum \limits_{m=1}^{n-1} m \left[\ln(m+1) - \ln(m)\right] = \sum \limits_{m=1}^{n-1} \left[(m+1)\ln(m+1) -  m  \ln(m) - \ln(m+1)\right] \\
&= \ln \left(\frac{n^n}{n!}\right)
\end{align}
for $n \in \mathbb{N}$ (exploiting that the first part of the final sum is telescoping). By the way, we can now use Stirling's formula to compute the limit
$$ \lim_{n \to \infty} I_n - n + \frac{1}{2} \ln(n) = - \frac{1}{2} \ln(2 \pi) \, .$$
