To give a more succinct explanation:georgeu2000 wrote:To Bhpillab,
Why is there a difference between flipping heads followed by tails and flipping two heads? If it is random, shouldn't the probability be the same?
Imagine the two cases where there is a mess up:
Consider the case HT:
A mess up would look like HH which can always be followed by a tails ( HHT finishes it)
Consider the case of HH:
A mess up would look like HT which needs at least two more coin flips to finish. (HTHH is required to finish)
This shows that it is shorter to get HT than it is to get HH.
I hope that this proves enlightening!
PS I ran my algorithm and your results match that of a H, HH, HHH, HHHH... I know texane had a similar error which restarted a success counter for every misstep, but this is only accurate in the case that all coins are showing the same face. Otherwise it was start you off at 1 again instead of 0.