OFFSET
1,2
MAPLE
s := proc(n) option remember; `if`(n < 1, 0, a(n) + s(n - 1)); end proc;
a := proc(n) option remember; `if`(n < 4, [1, 2, 4][n], s(n - 1) + a(-2^ceil(log[2](n - 1) - 1) + n - 1)); end proc;
seq(a(n), n = 1 .. 40); # Petros Hadjicostas, Apr 23 2020
PROG
(PARI) lista(nn) = { my(va = vector(nn)); va[1] = 1; va[2] = 2; va[3] = 4; my(sa = vecsum(va)); for (n=4, nn, va[n] = sa + va[n - 1 - 2^ceil(-1 + log(n-1)/log(2))]; sa += va[n]; ); va; } \\ Petros Hadjicostas, Apr 26 2020 (with nn > 2).
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
Name edited by Petros Hadjicostas, Apr 23 2020
STATUS
approved