TITLE: Finding how many 8-bit bytes contain an even number of zeros . . .
QUESTION [15 upvotes]: I believe I'm overthinking this or otherwise confused but I believe that the method to solve this would be $2^n$ where n is the length of the bytes? So in this particular case it would be $2^8$ equal 256 possible.
But then I feel like that isn't right and I'm mixed up. What I thought about is that there is 4 possible ways to have an even number f zeros (i.e. 2 zeros, 4 zeros, 6 zeros, or 8 zeros).
Any insight would be awesome as I'm confused...

REPLY [3 votes]: Here's another way. The number of bytes with $n$ zeroes is the coefficient of $x^n$ in $$(1+x)^8$$
Now for any polynomial $p(x)$, the sum of the coefficients of even degree is $\frac{p(1)+p(-1)}{2}$. Hence the answer is:
$$\frac{(1+1)^8+(1-1)^8}{2} =2^7$$