10. Even number of successes. Find the probability that heads will appear an even number of times, in an experiment where:

a) a fair coin is tossed $n$ times;

b) a coin, for which the probability of heads on a single toss is $p(0<p<1)$, is tossed $n$ times.
Solution. We will solve problem b), thereby obtaining the answer to question a) as well. The probability that heads will appear exactly $k$ times, as is known, is

$$
C_{n}^{k} p^{k} q^{n-k}
$$

where $q=1-p$ is the probability of tails. Therefore, the event "Heads appeared an even number of times" has the probability

$$
P_{2}=C_{n}^{0} p^{0} q^{n}+C_{n}^{2} p^{2} q^{n-2}+C_{n}^{4} p^{4} q^{n-4}+\ldots+C_{n}^{k} p^{k} q^{n-k}
$$

where $k$ is the largest even number not exceeding $n$, and $k$ can equal $n$.

The complement of this event is the event "Heads appeared an odd number of times." The probability of this is obtained similarly by replacing even indices and powers with odd ones:

$$
P_{1}=C_{n}^{1} p^{1} q^{n-1}+C_{n}^{3} p^{3} q^{n-3}+C_{n}^{5} p^{5} q^{n-5}+\ldots+C_{n}^{m} p^{m} q^{n-m}
$$

where $m$ is the largest odd number not exceeding $n$, and $m$ can equal $n$. Consider the difference of these probabilities:

$$
P_{2}-P_{1}=C_{n}^{0} p^{0} q^{n}-C_{n}^{1} p^{1} q^{n-1}+C_{n}^{2} p^{2} q^{n-2}-C_{n}^{3} p^{3} q^{n-3}+\ldots \pm C_{n}^{n} p^{n} q^{0}
$$

If $n$ is even, then the last term has a plus sign, if $n$ is odd, then a minus sign. In any case, $P_{2}-P_{1}=(q-p)^{n}$. On the other hand, $P_{2}+P_{1}=1$. From the system of obtained equations, we find:

$$
P_{2}=\frac{1+(q-p)^{n}}{2}=\frac{1+(1-2 p)^{n}}{2}
$$

In particular, for a symmetric coin $p=q=0.5$, so $P_{2}=0.5$.

Answer: a) 0.5; b) $\frac{1+(1-2 p)^{n}}{2}$.