<s>[INST] Expected Number of Coin Tosses to Get Five Consecutive Heads A fair coin is tossed repeatedly until 5 consecutive heads occurs. 
What is the expected number of coin tosses?
 [/INST] Here is a generating function approach.
Consider the following toss strings, probabilities, and terms
$$
\color{#00A000}{
\begin{array}{llc}
T&\frac12&\qquad\frac12x\\
HT&\frac14&\qquad\frac14x^2\\
HHT&\frac18&\qquad\frac18x^3\\
HHHT&\frac1{16}&\qquad\frac1{16}x^4\\
HHHHT&\frac1{32}&\qquad\frac1{32}x^5\\
\color{#C00000}{HHHHH}&\color{#C00000}{\frac1{32}}&\color{#C00000}{\qquad\frac1{32}x^5}
\end{array}
}
$$
Each term has the probability as its coefficient and the length of the string as its exponent.
Possible outcomes are any combination of the green strings followed by the red string. We get the generating function of the probability of ending after $n$ tosses to be
$$
\begin{align}
f(x)&=\sum_{k=0}^\infty\left(\frac12x+\frac14x^2+\frac18x^3+\frac1{16}x^4+\frac1{32}x^5\right)^k\frac1{32}x^5\\
&=\frac{\frac1{32}x^5}{1-\left(\frac12x+\frac14x^2+\frac18x^3+\frac1{16}x^4+\frac1{32}x^5\right)}\\
&=\frac{\frac1{32}x^5}{1-\frac{\frac12x-\frac1{64}x^6}{1-\frac12x}}\\
&=\frac{\frac1{32}x^5-\frac1{64}x^6}{1-x+\frac1{64}x^6}
\end{align}
$$
The average duration is then
$$
\begin{align}
f'(1)
&=\left.\frac{\left(\frac5{32}x^4-\frac6{64}x^5\right)\left(1-x+\frac1{64}x^6\right)-\left(\frac1{32}x^5-\frac1{64}x^6\right)\left(-1+\frac6{64}x^5\right)}{\left(1-x+\frac1{64}x^6\right)^2}\right|_{\large x=1}\\
&=\frac{\frac4{64}\frac1{64}+\frac1{64}\frac{58}{64}}{\left(\frac1{64}\right)^2}\\[12pt]
&=62
\end{align}
$$
</s>