I have the following GRE question that I have no idea how to solve.
Let $\left \lfloor x \right \rfloor$ denote the greatest integer not exceeding $x$. Evaluate $\int_0^\infty \left \lfloor x \right \rfloor e^{-x} \,\mathrm{d}x$.
The answer says it should be $\frac{1}{e-1}$, and a hint that they give is
$$ \int\limits_0^\infty \left \lfloor x \right \rfloor e^{-x} \,\mathrm{d}x = \sum_{n=1}^\infty \int\limits_n^{n+1} ne^{-x} \,\mathrm{d}x\,. $$
I don't really see how we go from the integral to the summation.
First note that $\int_0^{\infty}\lfloor x\rfloor e^{-x}\;dx=\sum_{n=0}^{\infty}\int_{n}^{n+1}\lfloor x\rfloor e^{-x}\;dx$ by the additivity of the integral.
This decomposition is useful because $\lfloor x\rfloor$ is equal to $n$ on the interval $[n,n+1)$. So we can rewrite the integral as $$ \sum_{n=0}^{\infty}\int_{n}^{n+1}\lfloor x\rfloor e^{-x}\;dx=\sum_{n=0}^{\infty}\int_{n}^{n+1}n e^{-x}\;dx$$ Finally, the sum can be changed to start at $n=1$ if we want, since the $n=0$ term is zero anyway.