Solution (source code)

= Solution

When $r$ red marbles remain, the next draw reduces their number with probability $r/n$. The waiting time $W_r$ for that reduction has a <geometric distribution> on $\{1,2,\ldots\}$ and therefore
$$
G_{W_r}(s)
=\frac{(r/n)s}{1-(1-r/n)s}
=\frac{rs}{n-(n-r)s}.
$$
The successive waiting times are independent, and
$$
T=W_n+W_{n-1}+\cdots+W_1.
$$
Using the product rule for probability-generating functions,
$$
\boxed{
G_T(s)=\prod_{r=1}^{n}
\frac{rs}{n-(n-r)s}}.
$$