OFFSET
0,3
COMMENTS
Hwang-Janson-Tsai paper, p. 39: "Note that the recurrence provided on OEIS for A090889 is incorrect (and the generating function misses a factor of 2)." - Michael De Vlieger, Oct 30 2022
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
Hsien-Kuei Hwang, Svante Janson, and Tsung-Hsi Tsai, Identities and periodic oscillations of divide-and-conquer recurrences splitting at half, arXiv:2210.10968 [cs.DS], 2022, p. 39.
FORMULA
MATHEMATICA
{0}~Join~Accumulate@ Accumulate@ Array[# IntegerExponent[#, 2] &, 43] (* Michael De Vlieger, Oct 30 2022 *)
PROG
(PARI) a(n)=sum(k=1, n, bitand(k, n-k)+k*(n-k))
(PARI) a(n)=if(n<1, 0, if(n%2==0, 2*a(n/2)+2*a(n/2-1)+n/2*(n/2+1)*(n+1)/3, 4*a((n-1)/2)+2/3*((n-1)/2)*((n-1)/2+1)*((n-1)/2+2)))
(PARI) a(n)=sum(l=0, n, sum(k=0, l, k*valuation(k, 2)))
(Python)
def A090889(n): return (sum(k&n-k for k in range(1, n+1>>1))<<1)+(0 if n&1 else n>>1)+n*(n-1)*(n+1)//6 # Chai Wah Wu, May 08 2023
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Ralf Stephan, Feb 13 2004
STATUS
approved