Solution (source code)

= Solution

Here $a+b/n=a(n+m-1)/n$, so iteration gives
$$
p_n=p_0a^n\frac{m(m+1)\cdots(m+n-1)}{n!}
=p_0\binom{m+n-1}{n}a^n.
$$
The negative-binomial series $\sum_{n\ge0}\binom{m+n-1}{n}a^n=(1-a)^{-m}$, valid for $0<a<1$, normalizes this to
$$
\boxed{p_n=\binom{m+n-1}{n}(1-a)^m a^n,\qquad n=0,1,\ldots.}
$$
This is the <negative binomial distribution> counting failures before the $m$th success, with success probability $1-a$. The convention is specified because a negative-binomial variable is sometimes defined to count trials instead. Its count <expected value> is $ma/(1-a)$, and the <Panjer recursion> begins at $g_0=(1-a)^m$. For $m=1$ this reduces to the failure-count <geometric distribution>.