What is the expected number of randomly generated numbers in the range [a, b] required to reach a sum $\geq X$? We are generating random numbers (integers) in the range $[a, b]$. All values are equally likely.
We will continue to generate random numbers in this range, and add up successive values until their combined sum is greater than or equal to a set number $X$.
What is the expected number of rolls to reach at least $X$?
Example:
a = 1000
b = 2000
X = 5000

Value 1: 1257 (total sum so far = 1257)
Value 2: 1889 (total sum so far = 3146)
Value 3: 1902 (total sum so far = 5048; all done)

So it took $3$ rolls to reach $\geq5000$. Intuitively, we can say that it will not take more than $5$ rolls if each roll is $1000$. We can also say that it will not take less than $3$ rolls if each roll was $2000$. So it stands to reason that in the example above, the expected number of rolls lies somewhere between $3$ and $5$.
How would this be solved in the general case for arbitrary values $[a, b]$ and $X$? It's been quite a while since I last took statistics, so I've forgotten how to work with discrete random variables and expected value.

The expected number is dominated by the term based on the mean $\frac{2X}{a+b}$ - but we can do better than that. As $X\to\infty$,
$$E(n) = \frac{2X}{a+b}+\frac{2(a^2+ab+b^2)}{3(a^2+2ab+b^2)}+o(1)$$
Why? Consider the excess. In the limit $X\to\infty$, the frequency of hitting a particular point approaches a uniform density of $\frac{2}{b+a}$. For points in $[X,X+a)$, this is certain to be the first time we've exceeded $X$, so the density function for that first time exceeding $X$ is approximately $\frac{2}{b+a}$ on that range. For $t\in[X+a,X+b)$, the probability that it's the first time exceeding $X$ is $\frac{X+b-t}{b-a}$; we need the last term added to be at least $t-X$. Multiply by $\frac{2}{b+a}$, and the density function for the first time exceeding $X$ is approximately $\frac{2(X+b-t)}{b^2-a^2}$ on $[X+a,X+b)$. For $t<X$ or $t\ge X+b$, of course, the density is zero. Graphically, this density is a rectangular piece followed by a triangle sloping to zero. Now, the expected value of the first sum to be greater than $X$ is approximately
$$\int_{X}^{X+a}\frac{2t}{b+a}\,dt+\int_{X+a}^{X+b}\frac{2t(X+b-t)}{b^2-a^2}\,dt$$
$$=\frac{2a(2X+a)}{2(b+a)}+\frac{2(b-a)(2X+a+b)(X+b)}{2(b^2-a^2)}-\frac{2(b-a)((X+a)^2+(X+a)(X+b)+(X+b)^2)}{3(b^2-a^2)}$$
$$=\frac{6aX+3a^2+6X^2+3(a+3b)X+3ab+3b^2-6X^2-6(a+b)X-2(a^2+ab+b^2)}{3(b+a)}$$
$$=\frac{3(a+b)X+a^2+ab+b^2}{3(b+a)}=X+\frac{a^2+ab+b^2}{3(a+b)}$$
Divide by the mean $\frac{a+b}{2}$ of each term in the sum, and we have an asymptotic expression for $E(n)$.
This is not a rigorous argument. If I wanted to do that, I'd bring out something like the moment-generating function.
