I am trying to find an easy way to calculate the number of times that the digit "$1$" appears in numbers $0-255$ (in the binary system). I consider the answer must be a power of $2$ since $256 = 2^8$ but I don't know how to approach this.
By symmetry, each of the eight bits is $1$ half the time (because, for instance, the number of numbers of the form $xxx1xxxx$ is equal to the number of numbers of the form $xxx0xxxx$).
So the total number of $1$'s is $\frac12(8\cdot 256)=1024$.
This is indeed a power of $2$, but only because $8$ is a power of $2$. In the range $0-127$, the total number of $1$'s is $\frac12(7\cdot 128)=448$, which is not a power of $2$.