I found a recent question on Mathematics Stack Exchange quite interesting. It simply asked
How does one easily calculate n=1∑∞n(n+1)pop(n) ?
Here pop(n) denotes the “population count” or “sideways sum”, which is the number of 1s in the binary representation of n (A000120).
The user achille hui provided a very nice answer which I would like to describe in some detail here. First, he introduces the function
θk(n)={1,0, if the kth bit of n is set, otherwise.
which makes it possible to write the series as
n=1∑∞n(n+1)pop(n)=n=1∑∞k=0∑∞n(n+1)θk(n)=k=0∑∞n=1∑∞n(n+1)θk(n).
After reversing the order of summation (which requires justification), he asks: For fixed k, which values of n has θk(n)=1? Note here that n has the kth bit set if and only if ⌊n/2k⌋ has the zeroth bit set. And a number has the zeroth bit set if and only if that number is odd. So θk(n)=1 if and only if ⌊n/2k⌋=2l+1 for some l=0,1,2,…. This means
θk(n)=1⇔2l+1≤n/2k<2l+2⇔(2l+1)2k≤n≤(2l+2)2k−1,
for some l=0,1,2,…. This provides us with the intervals of n that we are interested in, so we have
n=1∑∞n(n+1)pop(n)=k=0∑∞n=1∑∞n(n+1)θk(n)=k=0∑∞l=0∑∞n=(2l+1)2k∑(2l+2)2k−1n(n+1)1=k=0∑∞l=0∑∞n=(2l+1)2k∑(2l+2)2k−1(n1−n+11)=k=0∑∞l=0∑∞((2l+1)2k1−(2l+2)2k1)=(k=0∑∞2−k)(m=1∑∞(−1)m+1m1)=2ln2
Here, both a telescoping sum, a geometric progression sum (see Nice Proof of a Geometric Progression Sum with r=1/2) and the power series for the natural logarithm of 2 occurs.
Very nice.