Let $X_1, X_2, X_3, \dots$ be independent exponential random variables with parameter $\lambda$. Let $Y = \max\{r : X_1 + X_2 + \cdots + X_r \le 1\}$. Prove that $Y$ is Poisson distributed with parameter $\lambda$.
My attempt:
$$P(Y=k)=P(X_1 + X_2 + \cdots + X_{k+1} \ge 1) \cdot P(X_1 + X_2 + \cdots + X_k \le1)$$
Now define $T_n=\sum_{i=1}^n X_i$.
Since $X_i$ are exponentially distributed it follows that $T_n \sim \Gamma(n, \lambda) $ with pdf $$f_{T_n}(x)=\frac{\lambda^nx^{n-1}e^{-\lambda x}}{(n-1)!}.$$
So $$P(Y=k) = \left( 1-\int_0^1 \frac{\lambda^{k+1}x^{k}e^{-\lambda x}}{k!}\right) \cdot \left(\int_0^1 \frac{\lambda^k x^{k-1}e^{-\lambda x}}{(k-1)!} \right)$$
Now obviously those integrals can't be computed to obtain the answear. Can anyone please help me abd tell me what's wrong with my solution?
First of all, two events $A=\{T_k\leq 1\}$ and $\overline B=\{T_{k+1}> 1\}$ are dependent since $T_{k+1}=T_k+X_{k+1}$. Therefore the probability of their intersection is not equal to the product of their probabilities. $$ \mathbb P(Y=k)=\mathbb P(T_k\leq 1, T_{k+1}> 1) = \mathbb P(A\cap \overline B) = \mathbb P(A) - \mathbb P(A\cap B) $$ Note that $B=\{T_{k+1}\leq 1\}\subseteq A=\{T_k\leq 1\}$, therefore $\mathbb P(A\cap B)=\mathbb P(B)$. Finally, $$ \mathbb P(Y=k)=\mathbb P(A) - \mathbb P(B) = \int_0^1 \frac{\lambda^{k}x^{k-1}e^{-\lambda x}}{(k-1)!}\,dx-\int_0^1 \frac{\lambda^{k+1}x^{k}e^{-\lambda x}}{k!}\,dx. $$ Try to integrate by parts in the second integral once, and you'll get desired result.