Solution (source code)

= Solution

Let $T$ count tests up to and including the first failure. By <independence of random variables>, the event $T=j$ requires $j-1$ passes and then a failure. With pass <probability> $p=1/2$ and failure <probability> $q=1/2$, this is the <geometric distribution>
$$
\mathbb P(T=j)=q p^{j-1},\qquad j=1,2,\ldots.
$$
Using part (iii), its <expected value> is
$$
\boxed{\mathbb E[T]=q\sum_{j=1}^{\infty}jp^{j-1}
=\frac{q}{(1-p)^2}=\frac1q=2.}
$$
This counts the test that discovers the fault. The expected number of earlier passing tests alone would be one.