Trivia
Larry Barrett
It would be the same game if they both start with the same number of coins, flip them all and count heads, and then A flips his extra coin.
In the cases where A has more heads than B after they flip n coins, the extra coin will not matter (A wins all), and will not matter in the cases where B has 2 or more heads than A after n flips (B wins all).
It will matter in the case where they both have the same number of heads after the first flip, and then A flips the extra coin - probablility = 1/2 that he gets a head and wins everything, and probability = 1/2 that he gets a tail and then they remain tied.
And in the case where B has one more head than A after the first n flips and A flips the extra coin probability = 1/2 that A gets a head and now they are tied, probability = 1/2 that he gets a tail, and in this case B still wins.
Once tied and they go into each flipping one coin, they both have even chance of winning all.
If we wanted to calculate the Expected winnings for A and for B we would need to calculate the probabilies in the two cases that matter, and that is not easy with 40 coins, but I think these are the only cases that matter.

