%I #34 Nov 21 2019 19:54:56
%S 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,
%T 21,46,14,39,30,55,1,37,26,62,17,53,42,78,10,46,35,71,26,62,51,87,5,
%U 41,30,66,21,57,46,82,14,50,39,75,30,66,55,91,1,50,37,86
%N a(0) = 0, a(n) = a(floor(n/2)) + (n mod 2) * floor(log_2(2n))^2 for n > 0.
%H Alois P. Heinz, <a href="/A329752/b329752.txt">Table of n, a(n) for n = 0..16383</a>
%F 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.
%F a(2^n-1) = n*(n+1)*(2*n+1)/6 = A000330(n).
%F a(2^n) = 1.
%F a(2^n+1) = n^2 + 1 = A002522(n).
%e For n = 11 = 1011_2 we have a(11) = 1^2 + 3^2 + 4^2 = 1 + 9 + 16 = 26.
%p a:= n-> (l-> add(l[-i]*i^2, i=1..nops(l)))(convert(n, base, 2)):
%p seq(a(n), n=0..80);
%p # second Maple program:
%p a:= proc(n) option remember; `if`(n=0, 0,
%p a(iquo(n, 2))+`if`(n::odd, ilog2(2*n)^2, 0))
%p end:
%p seq(a(n), n=0..80);
%Y Cf. A000079, A000225, A000290, A000330, A000523, A002522, A008935, A029837, A029931, A070939, A113473, A230877.
%K nonn,look
%O 0,4
%A _Alois P. Heinz_, Nov 20 2019
|