Solution (source code)

= Solution

The $X_i$ are independent <Bernoulli random variables> with success parameter $p$. Their sum has the \b[<binomial distribution> $S_n\sim\operatorname{Bin}(n,p)$], whose <probability mass function> is
$$
\boxed{\mathbb P(S_n=k)=\binom nk p^k(1-p)^{n-k},\qquad k=0,\ldots,n.}
$$
Choose the $k$ successful events in $\binom nk$ ways; <independence> gives the same product probability for each choice. At $p=0$ or $p=1$, interpret the formula by its degenerate distribution or by continuity.