A quick check reveals that the probability of going bust after $1$ step is given by $C_0(1-p)$. Here $C_i$ is the $i$-th Catalan number. Going bust after $3$ steps is given by $C_1p(1-p)^2$ and $5$ steps is given by $C_2p^2(1-p)^3$, So we can see the pattern. So the answer for your question is the following sum: $$(1-p)\sum_{i=0}^{\infty}(2i+1)C_i(p(1-p))^i$$ You can calculate the sum by using the well-known generating function for the Catalan numbers: $$c(x)=\sum_{i=0}^{\infty}C_ix^i=\frac{1-\sqrt{1-4x}}{2x}$$ Now if you look at $\frac{d (xc(x^2))}{dx}$ and then plug in $x=p(1-p)$ and then multiply by $1-p$ you get the answer given by the series above.
user127776
- 5.9k
- 2
- 9
- 24