= Solution
Let $X_1$ and $X_2$ denote the first and second labels. <Sampling with replacement> restores the bag before the second draw, so conditioning on $X_1=x$ only specifies the threshold. For $1\leq x\leq g$, there are $x$ qualifying green balls and $x$ qualifying red balls. For $g<x\leq r$, every green ball and the first $x$ red balls qualify. Hence the requested <conditional probability> is
$$
\boxed{\mathbb P(X_2\leq x\mid X_1=x)=
\begin{cases}
\dfrac{2x}{g+r},&1\leq x\leq g,\\[4pt]
\dfrac{g+x}{g+r},&g<x\leq r.
\end{cases}}
$$
The formulas agree at $x=g$ and give one at $x=r$. Labels outside the possible first-draw range do not define a conditioning event of positive <probability>.
Back to article page