How many games will you play and how many of those games will you lose? Each time you play a game, you win with probability p. (The games are independent.) You plan
to play 5 games, but if you win the fifth game, then you will keep on playing until you lose.
(a) Find the expected number of games that you play.
(b) Find the expected number of games that you lose.
I'm not sure how to account for games that you play past the 5 games. I know that if you have a p% chance of winning the game you would only have to check on the 5th game and onward whether you win or not. But how would I go about doing so?
 A: (1) If you win the fifth game, you play on average $\frac1{1-p}$ extra games (the geometric distribution here has "success" probability $1-p$ because in this phase a failure, where we keep going, is a win). Therefore the expected number of games played is $5+\frac p{1-p}$.
(2) In the first four games, you are expected to lose $4(1-p)$ games on average. If you lose the fifth game, with probability $1-p$, that's it; if you win the fifth game there is exactly one loss ahead of you. Thus the number of games lost after game $4$ is constant $1$, and the expected number of games lost is $4(1-p)+1$.
A: You play exactly $n\ge5$ games iff the $n^\text{th}$ game is a loss and games $5$ through $n-1$ are wins. Games $1$ through $4$ may be wins or losses. The probability associated with playing $n$ games is thus $p^{n-5}(1-p),n\ge5$. You should be able to solve for the expectation.
Suppose you lose exactly $m\ge1$ times in $n$ games. Then games $5$ through $n-1$ are surely wins and the last game is surely a loss. Then games $1$ through $4$ must contain $m-1$ losses i.e. $m-1\le4\implies m\le5$. The probability associated with $m$ losses is $\binom 4{m-1}(1-p)^{m-1}p^{5-m}$. Can you find the expectation?
