Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

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} $?

I checked OEIS and didn't find information about this sequence (1,1,2,2,2,3,1,2,2,3,...)

share|improve this question
5  
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
2  
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

2 Answers 2

up vote 17 down vote accepted

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)

share|improve this answer

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 .

share|improve this answer
3  
This hsould be a comment –  Darkhogg Mar 25 at 22:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.