I have been given this question, but I don't get what to do.
I know I am supposed to condition on another variable, call it $Y$, which equals the number of flips until the first occurrence of tails.
$$E(X)=E(E(X|Y))=\sum_iE(X|Y=i)p(Y=i)\\ p(Y=i)=p^{i-1}(1-p)=> E(X) = (1-p)\sum_iE(X|Y=i)p^{i-1}$$ I can't figure out why, but I read that $E(X|Y=i)=i+E(X)$ for $i\in[1,r]$
Why does $\sum_xXp(X=x|Y=i)=i+E(X)???$
