# Number of 1 in binary representation of n

Let $1(n)$ be the number of digits $1$ in binary representation of number $n$.

For example, $13=1101_2$ so $1(13)=3\\$

Is there explicit form of $\,\,\sum{1(i)x^i}$?

-
oeis.org/A000120 –  Zack Wolske Mar 25 at 17:56
Can you be more explicit how to obtain the sequence? –  Stephan Müller Mar 25 at 18:06
Your version is missing $1(4)=1$ –  Henry Mar 25 at 22:56
For those looking to actually count binary 1s in computer program code, you may enjoy reading fast bit-counting routines. –  ErikE Mar 25 at 23:18

The generating function you ask about, more typically written as $\sum_{i\ge 0} s_2(i) x^i$, can be expressed as $$\frac{1}{1-x} \sum_{m\ge 0} \frac{x^{2^m}}{1+x^{2^m}}$$ The number of 1's in the binary expansion is just the sums of digits; there also exists a generalization for sums of digits function in other bases. For details, references and further information, see for example "Generating Functions for the Digital Sum and Other Digit Counting Sequences" by Adams-Watters and Ruskey (Journal of Integer Sequences, 2009)

-

By the way, the reason why the OP did not find the sequence in the OEIS is that he/she wrote down the first few terms incorrectly. They are 0,1,1,2,1,2,2,3, ..., which is sequence http://oeis.org/A000120 .

-
This hsould be a comment –  Darkhogg Mar 25 at 22:51