Finding how many 8-bit bytes contain an even number of zeros . . .

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...


Solution 1:

Any $7$-bit word can be completed to an $8$-bit word with an even number of $0$'s in exactly one way by choosing the eighth bit suitably. So the number of $8$-bit words with an even number of $0$'s is the same as the number of $7$-bit words. This is $2^7$.

Solution 2:

HINT

Divide the cases for the number of zeros, namely $0,2,4,6,8$, which gives us $$\binom{8}{0}+\binom{8}{2}+\binom{8}{4}+\binom{8}{6}+\binom{8}{8}=\frac{2^8}{2}$$ From the Binomial Theorem.

You could also use recurrence relations to solve this problem.