OFFSET
0,2
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..16384
Ralf Stephan, Some divide-and-conquer sequences ...
Ralf Stephan, Table of generating functions
FORMULA
a(n) = a((n - n mod 2) / (2 - n mod 2)) + 1 for n>0, a(0)=1. - Reinhard Zumkeller, Jul 29 2002
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
EXAMPLE
12 = 1100 in binary, so a(12)=2+4=6.
MATHEMATICA
Table[If[n==0, 1, s=IntegerDigits[n, 2]; Total@s+Length@s], {n, 0, 100}] (* Giorgos Kalogeropoulos, Sep 13 2021 *)
PROG
(PARI) a(n) = if (n==0, 1, my(b=binary(n)); vecsum(b) + #b); \\ Michel Marcus, Sep 13 2021
(Python)
def a(n): b = bin(n)[2:]; return b.count('1') + len(b)
print([a(n) for n in range(87)]) # Michael S. Branicky, Sep 13 2021
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
N. J. A. Sloane, Sep 01 2000
EXTENSIONS
More terms from James A. Sellers, Sep 06 2000 and from David W. Wilson, Sep 07 2000
STATUS
approved