$p$ is the probability of getting a Head.
So the expected number of coin tosses before getting $h$ consecutive heads for the first time is:
$E(x) = hp^h + (1-p)[E(x)+1] + p(1-p)[E(x)+2] + p^2(1-p)[E(x)+3]+ ... + p^{h-1}(1-p)[E(x)+h]$
$E(x) = hp^h + (1-p)\sum_{i=0}^{h-1}p^i[E(x)+i+1]$ --------> (2)
$E(x) = (1-p^h)E(x)+\sum_{i=0}^{h-1}p^i$ --------> (3)
$E(x) = (1-p^h)E(x)+\frac{1-p^h}{1-p}$ --------> (4)
$E(x)=\frac{1-p^h}{p^h(1-p)}$ --------> (5)
I got this from the answer here. I dont understand how we get expression 3 from expression 2. Can someone please explain that.