OFFSET
0,3
FORMULA
Recurrence: a(2n) = 3a(n) + n, a(2n+1) = 3a(n) + n + 1.
G.f.: 1/(1-x) * sum(k>=0, 3^k*t/(1-t^2), t=x^2^k).
PROG
(PARI) a(n)=sum(k=1, n, 3^valuation(n, 2))
(PARI) a(n)=if(n<1, 0, if(n%2==0, 3*a(n/2)+n/2, 3*a((n-1)/2)+(n+1)/2))
(Python)
def A091311(n): return (int(bin(n)[2:], 3)<<1)-n # Chai Wah Wu, Jul 07 2022
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Ralf Stephan, Feb 24 2004
STATUS
approved