There are $n$ children in a class. Teacher gives them all red pencils: each child, independently, may not to take red pencil with probability $p_1$. Then teacher gives them all green pencils: each child may not to take green pencil with probability also $p_1;$ some children can have two pencils. Compute probability that teacher gave the same number of red and green pencil.
By Bernoulli process we know that for fixed $0\leq k \leq n$ probability that teacher gave $k$ red pencils is equal ${n \choose k}(1-p_1)^kp_1^{n-k}.$ Similarly, probability that teacher gave $k$ green pencils is the same. From independence we have that probability that teacher gave $k$ pencils red and $k$ pencils green is ${n\choose k}^2 p_1^{2(n-k)}(1-p_1)^{2k}$ and probability which we want to compute is equal $\sum_{i=0}^n {n\choose k}^2 p_1^{2(n-k)}(1-p_1)^{2k}.$ I have a trouble to compute this sum. Maybe I make mistakes? Or maybe there is easier or better, more didactic, solution? I would be very grateful for your help.