OFFSET
1,2
LINKS
Michael De Vlieger, Table of n, a(n) for n = 1..3327
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, 1][n], s(n - 1) - a(-2^ceil(log[2](n - 1)) + 2*n - 3)):
end proc:
seq(a(n), n = 1..40); # Petros Hadjicostas, Nov 15 2019
MATHEMATICA
Nest[Append[#1, Total@ #1 - #1[[2 #2 - 3 - 2^Ceiling@ Log2[#2 - 1]]]] & @@ {#, Length@ # + 1} &, {1, 2, 1}, 34] (* Michael De Vlieger, Nov 19 2019 *)
PROG
(PARI) lista(nn) = {my(va = vector(nn), s); va[1] = 1; va[2] = 2; va[3] = 1; s = sum(k=1, 3, va[k]); for (n=4, nn, va[n] = s - va[2*n - 3 - 2^ceil(log(n-1)/log(2))]; s += va[n]; ); va; } \\ Michel Marcus, Nov 20 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
Name edited by and more terms from Petros Hadjicostas, Nov 15 2019
STATUS
approved