TITLE: GRE question: Evaluate $\int_0^\infty \left \lfloor x \right \rfloor e^{-x} \,\mathrm{d}x$
QUESTION [7 upvotes]: 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.

REPLY [6 votes]: Probabilistically, this is asking about $\mathbf{E}[\lfloor X\rfloor]$ where $X\sim \mathrm{Exp}(1)$. 
It is well known that if $X\sim \mathrm{Exp}(\lambda)$, then $\lfloor X \rfloor$ is geometrically distributed which value is starting from $0$. Let $n\geq 0$ be a given nonnegative integer. Then we have
$$
P(\lfloor X \rfloor \geq n) = P(X\geq n) = e^{-\lambda n}.  
$$
Thus, it follows that $\lfloor X \rfloor$ is geometrically distributed  with parameter $p=1-e^{-\lambda}$ which starts with value $0$. This has expectation $\frac 1p -1$. 
In the problem we have $\lambda =1$. Thus, the answer is 
$$
\mathbf{E}[ \lfloor X \rfloor ] = \frac { e^{-1} }{1-e^{-1} } = \frac 1{e-1}.
$$