probability – Why is the conditional expectation failed case written this way?

This is my first post and I apologize in advance if I’m not using the right formatting/approach.


A coin, having probability p of landing heads, is continually flipped until at least one head and one tail have been flipped.

Find the expected number of flips needed.

typical examples: “HT”, X = 2; “TTTTH”, X = 5.

Solution Begin

Denote X: # of flips needed. Y: outcome of 1st flip.

$E(X) = E(X|Y = H)P(Y = H) + E(X|Y = T)P(Y = T)$

$E(X|Y = H) = 1 + $E(additionalflips needed)$ = 1 + 1/(1-p)$


This is regarding $$1 + 1/(1-p)$$

I understand that 1 is for the failed trial but why is the 1/(1-p) there? Given the conditional probability/expectation, I thought the denominator would be the P(Y=H) which is p. I just don’t understand the overall reason for 1/(1-p). Could someone help me understand or point me in the right direction?