A coin with probability $p$ of landing a head is tossed repeatedly till the occurrence of two consecutive heads. Let $X$ be the random variable denoting the the number of trials needed. What is the distribution of $X$?
We consider a partition of the sample space where the sequence of events begins with a $T$, an $HT$ and an $HH$. So we have,
\begin{align} \mathbb{E}(X)&=\mathbb{E}(X\mid T)\mathbb{P}(T)+\mathbb{E}(X\mid HT)\mathbb{P}(HT)+\mathbb{E}(X\mid HH)\mathbb{P}(HH) \\&=\mathbb{E}(X+1)q+\mathbb{E}(X+2)pq+2p^2\qquad,\,q=1-p \end{align}
Thus in general for a function $g$ we have,
$$\mathbb{E}(g(X))=\mathbb{E}(g(X+1))q+\mathbb{E}(g(X+2))pq+g(2)p^2$$
Let $g(X)=t^X$, so that we get the PGF of $X$ as
\begin{align} P(t)=\mathbb{E}(t^X)&=tqP(t)+t^2pqP(t)+t^2p^2 \\&=p^2t^2(1-qt-pqt^2)^{-1} \end{align}
Now to get the p.m.f. of $X$ I need to find the coefficient of $t^j$ in the expansion of $P(t)$.
$$P(t)=p^2t^2(1-qt(1+pt))^{-1}=p^2t^2\sum_{j=0}^\infty(qt(1+pt))^j\,,$$
assuming $|qt(1+pt)|<1$.
But I could not separate the $t^j$ and its coefficient in the above expression.