This is not nearly as elegant as GoblinGuide's simple answer:
https://puzzling.stackexchange.com/a/126192/1777
The probability of winning is always:
50%
Strategy:
Strategy:
1) Never fix a tails, if done, then a loss occurs
2) If there are no live coins left, a win occurs
3) Fix some non-zero number of heads, and continue
For any given N coins, there is:
1) exactly one way to immediately lose (flip all tails)
2) exactly one way to immediately win (flip all heads)
3) 2^N - 2 options that allow to fix a number of heads.
The probability of winning with zero live coins is 100%.
The probability of winning with one live coin is 50%, either a heads is flipped and a win occurs, or a tails is flipped and a loss occurs.
The probability of winning with two live coins is also 50%. 25% of the time, two heads are flipped and a win occurs. 25% of the time, two tails are flipped and a loss occurs. The other 50% of the time, we lock one heads and continue with one coin, which has been illustrated to win 50% of the time.
The probability of winning with three live coins is also 50%. 12.5% of the time three heads are flipped and a win occurs. 12.5% of the time, three tails are flipped and a loss occurs. The other 75% of the time, we lock one or two heads and continue with those fewer coins and this has been illustrated to be 50%.
This generalizes to:
Pwin(N live coins) = ((1.0) + 0.5 * (2^N - 2)) / 2^N
Pwin = (1 + 2^(N-1) - 1) / 2^N
Pwin = 2^(N-1) / 2^N
Pwin = 2^(N-1) / (2 * 2^(N-1))
Pwin = 1 / 2