<s>[INST] Suppose that we flip a coin until either it comes up tails twice or we have flipped six times. What is the expected number of times we flip the coin? So this is the answer that I got (where $N$ represents the number of coin flips after which you can stop) but can someone tell me if this looks right?
$P(N=2) = P(TT) = \dfrac{1}{4} $
$P(N=3) = P(HTT , THT) = \dfrac{2}{8} $
$P(N=4) = P(HHTT;HTHT;THHT) = \dfrac{3}{16} $
$P(N=5) = \dfrac{4}{32} $
$P(N=6) = 1 - \dfrac{1}{4} - \dfrac{2}{8} - \dfrac{3}{16} - \dfrac{4}{32} = \dfrac{3}{16}$
$E(N) = 2\left(\dfrac{1}{4}\right) + 3\left(\dfrac{2}{8}\right) + 4\left(\dfrac{3}{16}\right) + 5\left(\dfrac{4}{32}\right) + 6\left(\dfrac{3}{16}\right) = \dfrac{15}{4} = 3.75$
 [/INST] What you are looking at is a right-censored negative binomial distribution.  That is, let $Y = X \wedge 6 = \min\{X, 6\}$ where $X \sim {\rm NegBinomial}(r = 2, p = 1/2)$, where the particular choice of parametrization for $X$ is $$\Pr[X = k] = \binom{k-1}{k-r} (1-p)^r p^{k-r}, \quad k = r, r+1, r+2, \ldots.$$  That is, $X$ counts the total number of trials needed to observe $r = 2$ tails, where each trial is an independent Bernoulli trial with probability of observing tails equal to $p = 1/2$.  Then $Y$ is $X$ right-censored at $6$.  So we can calculate $$\begin{align*} {\rm E}[Y] &= {\rm E}[X \wedge 6] \\ &= \sum_{k=2}^5 k \Pr[X = k] + \sum_{k=6}^\infty 6 \Pr[X = k] \\ &= 6 - \sum_{k=2}^5 (6-k)\Pr[X = k] \\ &= 6 - \frac{9}{4} = \frac{15}{4}.\end{align*}$$
</s>