This is the exact question:



> 
> You are given black-box which returns a random number between 0 and 1(uniform distribution).You keep generating random numbers X1,X2,X3 and so on and store the sum of all those random numbers. You stop as soon as the sum exceeds 1.What is the expected number of random variables used in the process?
> 
> 
> 


How I went about solving this is to find the probability that N random variables are required and S = event that sum exceeds 1.


For N=1, P(S) = 0.


For N=2, P(S) = 1/2 ( X1 + X2 > 1, when (X1,X2) lies above the line X1 + X2 = 1 where 0 < X1,X2 < 1. Area of triangle fulfilling the criteria is 1/2 )


For N=3, P(S) = 1/2 \* 5/6 ( X1 + X2 + X3 > 1. This holds when X1 + X2 > 1 - X3 and integrating over all values of X3 gave the probability to be 5/6 which is multiplied with 1/2 because X1 + X2 < 1)


This seems to be a rather lengthy way to approach this problem. Is there a shorter more intuitive method?



What is the expected number of random numbers (generated uniformly) such that their sum of numbers exceeds one?
For any random variable $X$ taking values in $\mathbb{N}$, $E[X]= \sum\_{n=0}^\infty P(X\gt n)$. In this case, the probability that the sum of the first $n$ numbers is less than $1$ is $1/n!$, the volume of the simplex with vertices at the origin and the standard basis vectors in $n$ dimensions. So, the expected number of draws needed to get a partial sum greater than $1$ is $\sum\_{n=0}^\infty 1/n! = e$.


Another approach is to set up a (lag-)differential equation for $f(x)$, the expected number of draws needed for the sum to exceed $x$. For $x \le 0, f(x) = 0$. For $x \gt 0, f(x) = 1+ \int\_{x-1}^x f(z) dz$, so $f'(x) = f(x)-f(x-1)$. This has the solution $f(x) = e^x, 0\lt x\le 1$. [Another recent question](https://mathoverflow.net/questions/141368/error-term-for-renewal-function) asked about the error from the asymptotic of $f(x) \sim 2x+2/3$. 


