Sum of series with binary parity in the numerator I'm now stuck with this question, and I don't eve

Izabella Ponce

Izabella Ponce

Answered question

2022-06-28

Sum of series with binary parity in the numerator
I'm now stuck with this question, and I don't even know where to start: Find sum of series
1 f ( n ) n ( n + 1 )
, where f(n) - number of ones in binary representation of n.
I wish I could post some moves, that I've tried but I don't know what to do.
Thanks!

Answer & Explanation

iceniessyoy

iceniessyoy

Beginner2022-06-29Added 27 answers

Maybe there is a quicker way, but here is one. Let the sum be S. We have
f ( n ) n ( n + 1 ) = f ( n ) n f ( n ) n + 1
f ( 2 n ) ( 2 n ) ( 2 n + 1 ) + f ( 2 n + 1 ) ( 2 n + 1 ) ( 2 n + 2 ) = f ( 2 n ) 2 n f ( 2 n ) f ( 2 n + 1 ) 2 n + 1 f ( 2 n + 1 ) 2 n + 2
Now f ( 2 n + 1 ) = f ( 2 n ) + 1 , f ( 2 n ) = f ( n ), so we can write:
f ( 2 n ) ( 2 n ) ( 2 n + 1 ) + f ( 2 n + 1 ) ( 2 n + 1 ) ( 2 n + 2 ) = f ( 2 n ) 2 n + 1 2 n + 1 f ( 2 n ) + 1 2 n + 2 = 1 2 ( f ( n ) n f ( n ) n + 1 ) + ( 1 2 n + 1 1 2 n + 2 )
S = 1 2 + 1 2 n = 1 f ( n ) n ( n + 1 ) + n = 1 ( 1 2 n + 1 1 2 n + 2 )
2 S = 1 + S + 2 log 2 1 S = 2 log 2 1.386
polivijuye

polivijuye

Beginner2022-06-30Added 16 answers

Code:
double sum=0;
for(int i=1;i<9999999;i++){
double s2=Integer.bitCount(i);
sum+=(s2)/(i*(i+1));
}
Output Data
n 9 1.065079365079365 99 1.3394382621894894 999 1.3800972409478014 9999 1.3854974129587205 99999 1.3852676077956714 ( limit of data type, therefore decreased value )

Do you have a similar question?

Recalculate according to your conditions!

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?