## coin flip question

A coin, having probability p of landing heads, is continually flipped until at least one head and one tail have been flipped.

a) find the expected number of flips needed.
b) Repeat a) in the case where flipping is continued until a total of at least two heads and one tail have been flipped.
c) Repeat a) in the case where flipping is continued until a total of at least two heads and two tail have been flipped.

a) I would think it would if $p<1-p$ then the expected number of flips would be $\frac{1}{p}$, and if $p>1-p$ then $\frac{1}{1-p}$.

b) $P(H\geq 2|T=1) = \frac{(1-P(H<2))}{T=1}$

$P(H<2) = P(H=0)+P(H=1)$ assuming there are n flips then you would have:

$1-\left[ \binom{n}{0}p^0(1-p)^n+\binom{n}{1}p^1(1-p)^{n-1} \right]$

combining it all together you would get :

$\frac{ 1-\left[ (1-p)^n+np(1-p)^{n-1} \right]}{1-p}$

c) This one I'm not sure, but I think it would be something like:

$\left(\frac{1}{p}\right)^{n+1}\times \left(\frac{1}{1-p}\right)^2+\left(\frac{1}{p}\right)^n \times \left(\frac{1}{1-p}\right) \times\left(\frac{1}{p}\right)^m \times \left(\frac{1}{1-p}\right)$ where $n,m\geq 1$

$= \left(\frac{1}{p}\right)^{n+1}\times \left(\frac{1}{1-p}\right)^2+\left(\frac{1}{p}\right)^{n+m} \times \left(\frac{1}{1-p}\right)^2$ where $n,m\geq 1$

$= \left(\frac{1}{1-p}\right)^2\times \left[\left(\frac{1}{p}\right)^{n+1}+\left(\frac{1}{p}\r ight)^{n+m} \right]$ where $n,m\geq 1$

at which point I'm stuck.