This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A230877 #23 Mar 18 2024 05:26:25 %S A230877 0,1,1,3,1,4,3,6,1,5,4,8,3,7,6,10,1,6,5,10,4,9,8,13,3,8,7,12,6,11,10, %T A230877 15,1,7,6,12,5,11,10,16,4,10,9,15,8,14,13,19,3,9,8,14,7,13,12,18,6,12, %U A230877 11,17,10,16,15,21,1,8,7,14,6,13,12,19,5,12,11,18,10,17,16,23,4,11,10,17,9,16,15,22,8,15,14 %N A230877 If n = Sum_{i=0..m} c(i)*2^i, c(i) = 0 or 1, then a(n) = Sum_{i=0..m} (m+1-i)*c(i). %C A230877 Suggested by Jon Perry's A231204, only now the leading power of 2 gets weight 1. %H A230877 Rémy Sigrist, <a href="/A230877/b230877.txt">Table of n, a(n) for n = 0..8192</a> %e A230877 For n=13 we have 1101, so we add 1+2+4, getting a(13)=7. %p A230877 f:=proc(n) local t1,m,i; %p A230877 t1:=convert(n,base,2); %p A230877 m:=nops(t1)-1; %p A230877 add((m+1-i)*t1[i+1], i=0..m); %p A230877 end; %t A230877 Array[Total[Position[IntegerDigits[#, 2], 1], 2] &, 100, 0] (* _Paolo Xausa_, Mar 18 2024 *) %o A230877 (PARI) a(n) = { my (b=binary(n)); sum(k=1, #b, b[k]*k) } \\ _Rémy Sigrist_, Jun 25 2021 %o A230877 (Python) %o A230877 def A230877(n): return sum(i for i, j in enumerate(bin(n)[2:],1) if j=='1') # _Chai Wah Wu_, Jan 09 2023 %Y A230877 Cf. A029931, A231204, A329752. %K A230877 nonn,base %O A230877 0,4 %A A230877 _N. J. A. Sloane_, Nov 08 2013