TITLE: Gambling puzzle
QUESTION [14 upvotes]: A math friend of mine showed me this strange gambling puzzle.  There is a button in a casino and every time you press it you can win either $1$ or $0$ dollars. The probability of winning $1$ dollar depends on how many times you have pressed it so far.  If you press it for the $x$-th time you have probability $x/M$ of winning a dollar. If $x$ gets to $M$ or greater then you just win a dollar every time. 
How many button presses do you expect to have to press to win $N$ dollars?

REPLY [2 votes]: In the case of $N \geq M$....
Let $W$ be the winnings after the first $M$ plays. Let $L$ be the number of plays required to win $N$ dollars.
Then $L = M + (N - W)$.
Thus we can compute
$$ E(L) = M + N - E(W) = M + N - \sum_{i=1}^M \frac{i}{M}
= \frac{1}{2}M + N - \frac{1}{2} $$
that is, on average, it takes $\frac{1}{2} M + N - \frac{1}{2}$ plays to win $N$ dollars.