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 A056791 #36 Jul 02 2025 16:02:00 %S A056791 1,2,3,4,4,5,5,6,5,6,6,7,6,7,7,8,6,7,7,8,7,8,8,9,7,8,8,9,8,9,9,10,7,8, %T A056791 8,9,8,9,9,10,8,9,9,10,9,10,10,11,8,9,9,10,9,10,10,11,9,10,10,11,10, %U A056791 11,11,12,8,9,9,10,9,10,10,11,9,10,10,11,10,11,11,12,9,10,10,11,10,11,11 %N A056791 Weight of binary expansion of n + length of binary expansion of n. %H A056791 Michael De Vlieger, <a href="/A056791/b056791.txt">Table of n, a(n) for n = 0..16384</a> %H A056791 Ralf Stephan, <a href="/somedcgf.html">Some divide-and-conquer sequences ...</a> %H A056791 Ralf Stephan, <a href="/A079944/a079944.ps">Table of generating functions</a> %H A056791 <a href="/index/Com#complexity">Index to sequences related to the complexity of n</a> %F A056791 a(n) = a((n - n mod 2) / (2 - n mod 2)) + 1 for n>0, a(0)=1. - _Reinhard Zumkeller_, Jul 29 2002 %F A056791 a(2n) = a(n)+1, a(2n+1) = a(n)+2. G.f.: 1 + 1/(1-x) * sum(k>=0, (2t+t^2)/(1+t), t=x^2^k). For n>0, a(n) = 2*A000120(n) + A080791(n) = A000120(n) + A029837(n). - _Ralf Stephan_, Jun 14 2003 %e A056791 12 = 1100 in binary, so a(12)=2+4=6. %t A056791 Table[If[n==0,1,s=IntegerDigits[n,2];Total@s+Length@s],{n,0,100}] (* _Giorgos Kalogeropoulos_, Sep 13 2021 *) %o A056791 (PARI) a(n) = if (n==0, 1, my(b=binary(n)); vecsum(b) + #b); \\ _Michel Marcus_, Sep 13 2021 %o A056791 (Python) %o A056791 def a(n): b = bin(n)[2:]; return b.count('1') + len(b) %o A056791 print([a(n) for n in range(87)]) # _Michael S. Branicky_, Sep 13 2021 %Y A056791 Equals A056792 + 1. %Y A056791 Equals A014701 + 2. %Y A056791 Cf. A061313, A037861. %K A056791 nonn,easy,base %O A056791 0,2 %A A056791 _N. J. A. Sloane_, Sep 01 2000 %E A056791 More terms from _James Sellers_, Sep 06 2000 and from _David W. Wilson_, Sep 07 2000