Source: (Harvard Statistics 110: see #17, p. 29 of pdf).
A couple decides to keep having children until they have at least one boy and at least one girl, and then stop. Assume they never have twins, that the "trials" are independent with probability 1/2 of a boy, and that they are fertile enough to keep producing children indefinitely. What is the expected number of children?
I would like to answer this question more generally with the probability of a boy being $p$ and the probability of a girl being $q$.
Let $C$ be a random variable denoting the number of children born until at least one boy and at least one girl is born.
Let $B$ be a random variable denoting the number of boys born until the first girl.
Let $G$ be a random variable denoting the number of girls born until the first boy.
Then the probability of $C$, the number of children being equal to $k$ is $$p^{k-1}q+q^{k-1}p$$
So
$$E(C)=q\sum_{k=2}^\infty kp^{k-1}+p\sum_{k=2}^\infty kq^{k-1}$$ $$=q \frac{d}{dp}(\frac{p^2}{1-p})+p\frac{d}{dq}(\frac{q^2}{1-q})$$ $$=1+\frac{p^2+q^2}{pq}$$
However, we could also think of the problem as $C=B+G$.
Now $$E(C)=E(B)+E(G)$$ however I cannot obtain my previous expression.