Bernoulli trials are run until 3 successful trials are completed. If probability of a success is 0.3 what is the expected number of failures? Bernoulli trials are run until 3 successful trials are completed. If probability of a success is 0.3 what is the expected number of failures?
My attempt:
Average number of successes in a n trials is $E[X] = np$. We know that the last trial must be a success, so perhaps we could find how many trails were likely made before the last trial in this way $n*0.3=2$, we get $n=6.7\approx 7$, then the answer is 7-2=5. I have no faith in this solution and I would like to see what you think is the correct way to solve this.

Let $p$ be the probability of success (here $p = 0.3$), and $q = 1 - p$, the probability of failure (here $q = 0.7$). $X = k$ if there are $k - 1$ trials with exactly $2$ successes and $k - 3$ failures, and the $k$th trial is success.
The probability of exactly $2$ successes in a sequence of $k - 1$ trials is $^{k-1}\text{C}_2\, p^2 q^{k - 3}$ (by using a binomial distribution with $n = k - 1$). Multiplying this with $p$, the probability of success in the $k$th trial, we obtain
$$P(X = k) = ^{k-1}\text{C}_2\, p^3 q^{k - 3},\ k = 3, 4, \ldots$$
$\begin{align}
E[X] & = \sum_{k = 3}^{\infty} kP(X = k)\\
\mu & = \sum_k \dfrac{k(k - 1)(k - 2)}{2} p^3 q^{k - 3}\\
 & = \dfrac{p^3}{2}\sum_k k(k - 1)(k - 2) q^{k - 3}\\
\int \mu\, dq & = \dfrac{p^3}{2}\sum_k k(k - 1) q^{k - 2}\\
\iint \mu\, dq\,dq & = \dfrac{p^3}{2}\sum_k k q^{k-1}\\
\iiint \mu\, dq\,dq\,dq & = \dfrac{p^3}{2}\sum_k q^k\\
 & = \dfrac{p^3}{2} \left(\dfrac{1}{1 - q}\right)\\
\mu & = \dfrac{p^3}{2}\dfrac{d^3}{dq^3}\left( \dfrac{1}{1 - q} \right)\\
& = \dfrac{p^3}{2}\left( \dfrac{6}{(1 - q)^4} \right)\\
& = \dfrac{p^3}{2}\left( \dfrac{6}{p^4} \right)\\
& = \boxed{\dfrac{3}{p}}
\end{align}$
Thus, the expected number of trials is $\dfrac{3}{p} = \dfrac{3}{0.3} = 10$. Then the expected number of failures is $10 - 3 = 7$.
