Probability: Store opening time Smith has a small booth where he sells lottery tickets. Customers arrive according to a Poisson
process of rate  $\lambda$= 1 per minute. He will close the shop on the 1st occasion that $a$  minutes
have elapsed since the last customer arrived.
let $X$ denote the first time when the gap between the arrival of
two consecutive customers is less than a. Find $E(X)$
Attempt:
I think $X$ is just exponential distributed, but $X=0$ for $x>a$. So $E[X]=\int_0^a\lambda x e^{-\lambda x}dx$.
What do you guys think?
 A: $X$ is not the length of the gap, $X$ is the time when the length of the gap is first of greater than $a$.  Call it a "long-gap", while a lesser length is a "short-gap".
To clarify:  Suppose some customers have arrived, all with a short-gaps before each and its previous, and then another customer arrives after a long-gap.   $X$ is the time of arrival of that customer.
Thus $X$ is the expected time a long-gap plus the expect count of short-gaps before the first long-gap times the expected time of any short-gap (since each is iid, and expectation is linear).
$$\begin{align}\mathsf E(X) ~ = & ~ \mathsf E(\mathsf E(\Delta T_{N+1}\mid \Delta T_{N+1}\geq a) + \mathsf E(\sum_{k=1}^N\Delta T_k\mid\forall k\leq N:\Delta T_k<a))
\\ = & ~ \mathsf E(\Delta T_{\ast}\mid \Delta T_{\ast}\geq a) +\mathsf E(N)\cdot\mathsf E(\Delta T_\ast\mid\Delta T_\ast<a)
\end{align}$$
Now the lengths of each gaps is iid exponentially distributed.
$$\Delta T_\ast \mathop{\sim}\limits^{iid} \mathcal {Exp}(1)$$
The count of short-gaps before the first long-gap is geometrically distributed, with success rate being the probability of a long-gap. 
$$N\sim\mathcal{Geo}_0(\mathsf P(\Delta T_\ast\geq a))$$
Can you complete?

(NB: "count of fails before success" is the $k\in\{0,1,...\}$ version of geometric distribution.)
A: We're computing $E X$ for $X$ taken as the time Smith closes his store (this is because the question seemed to ask that - recent comment shows differently, but the proof is similar). 
The interarrival times are indeed IID exponential with rate $1$. Denote them by $T_1,T_2,\dots$ ($T_1$ time the first customer arrives, $T_2$ time between first and second customer, etc.). 
Let $M=\min\{n: T_n \ge a\}$. Then 


*

*$M$ is geometric with parameter $ \int_a^{\infty} e^{-t} dt = e^{-a}$. 

*$X = \sum_{i<M} T_i + a$. 


Now compute $EX$. We do this by conditioning on $M$: 
$$ E X = \sum_{j=1}^\infty E[ X |M=j] P(M=j)= a + \sum_{j=1}^{\infty} (j-1) E [T_1| M=j] P(M=j).$$ 
Where the last equality is due to the fact that conditioned on $\{M=j\}$, $T_1,\dots ,T_{j-1}$ are IID. Now 
$$\{M=j\}=\{T_1 <a\}\cap \{T_2 < a\}\dots \cap \{T_{j-1}<a\}\cap \{T_j\ge a\}.$$ 
All but the first event in the intersection on the RHS but the first are independent of $T_1$. Therefore for $j>1$  (note that $j=1$ does not contribute in sum above): 
$$ E [ T_1 | M=j] =  E [ T_1 | T_1 <a] = \frac{  \int_0^a t e^{-t}dt}{ \int_0^a e^{-t} dt}=\frac{1-e^{-a}(1+a)} {1-e^{-a}}.$$
Putting this back into our formula, we have 
$$\begin{align*} E X & = a+ \frac{1-e^{-a}(1+a)} {1-e^{-a}} E (M-1) \\
 & = a + \frac{1-e^{-a}(1+a)} {1-e^{-a}} (e^a-1)\\
& = a + e^a-(1+a)=e^a -1.
\end{align*}$$  
