# Probability of even number of heads given 99 fair and 1 unfair coin

What's the probability of flipping an even number of heads after tossing 99 fair coins and one weighted coin. I don't know if this matters, but let's say the probability of the weighted coin landing heads is p.

Is the following correct:

P(even in 99 flips)*P(tails on last flip) + P(odd in 99 flips)P(heads in last flip) (1/2)[(99/100)(1/2) + (1/100)(1-p)] + (1/2)*[(1/2)(99/100) + (1/100)(p)]

This gets 1/2, but this doesn't logically make sense to me, because what is the last coin is p=0. Shouldn't it be less/more likely?

Thanks!

If we flip $$99$$ fair coins, the probability of getting an even number of heads is $$\frac12$$. To see this, observe that for any $$k$$ from $$0$$ through $$99$$, the probability of getting $$k$$ heads and $$99-k$$ tails is the same as the probability of getting $$k$$ tails and $$99-k$$ heads. The probability of getting an even number of heads is
$$\sum_{k=0}^{49}P(2k\text{ heads})=\sum_{k=0}^{49}P(2k\text{ tails})=\sum_{k=0}^{49}P(99-2k\text{ heads})\;,$$
which is the probability of getting an odd number of heads, since $$99-2k$$ runs through the odd numbers from $$99$$ down through $$1$$. Since the two are equal, both are $$\frac12$$.
Thus, it doesn’t matter how the weighted coin lands. If it lands tails, the probability that the total number of heads is even is the probability that the $$99$$ fair coins produced an even number of heads, which is $$\frac12$$. If it lands heads, the probability that the total number of heads is even is the probability that the $$99$$ fair coins produced an odd number of heads, which is also $$\frac12$$.
Let $$p_{n}$$ be the probabilty of getting an even number of head with $$n$$ fair and one biased coin. To get an even number of heads with $$n+1$$ fair and one biased coin means to either get an even number with the first $$n$$ fair plus one unfair coins and tails with the last fair coin, or an odd number with the first and heads with the last coin. So $$p_{n+1}=\frac12p_n+\frac12(1-p_n)=\frac12.$$