login
A329752
a(0) = 0, a(n) = a(floor(n/2)) + (n mod 2) * floor(log_2(2n))^2 for n > 0.
2
0, 1, 1, 5, 1, 10, 5, 14, 1, 17, 10, 26, 5, 21, 14, 30, 1, 26, 17, 42, 10, 35, 26, 51, 5, 30, 21, 46, 14, 39, 30, 55, 1, 37, 26, 62, 17, 53, 42, 78, 10, 46, 35, 71, 26, 62, 51, 87, 5, 41, 30, 66, 21, 57, 46, 82, 14, 50, 39, 75, 30, 66, 55, 91, 1, 50, 37, 86
OFFSET
0,4
LINKS
FORMULA
If n = Sum_{i=0..m} c(i)*2^i, c(i) = 0 or 1, then a(n) = Sum_{i=0..m} c(i)*(m+1-i)^2.
a(2^n-1) = n*(n+1)*(2*n+1)/6 = A000330(n).
a(2^n) = 1.
a(2^n+1) = n^2 + 1 = A002522(n).
EXAMPLE
For n = 11 = 1011_2 we have a(11) = 1^2 + 3^2 + 4^2 = 1 + 9 + 16 = 26.
MAPLE
a:= n-> (l-> add(l[-i]*i^2, i=1..nops(l)))(convert(n, base, 2)):
seq(a(n), n=0..80);
# second Maple program:
a:= proc(n) option remember; `if`(n=0, 0,
a(iquo(n, 2))+`if`(n::odd, ilog2(2*n)^2, 0))
end:
seq(a(n), n=0..80);
KEYWORD
nonn,look
AUTHOR
Alois P. Heinz, Nov 20 2019
STATUS
approved