Yes, it looks a little... nonobvious.
The easiest thing is to immediately apply the Binomial theorem: . Maybe they factored first: .
I'm looking at this page: Bernoulli Distribution -- from Wolfram MathWorld
I think I'm missing something simple, but how do you get from equation 24 to 25?
Thanks!