login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A049900
a(n) = a(1) + a(2) + ... + a(n-1) - a(m) for n >= 4, where m = 2*n - 3 - 2^(p+1) and p is the unique integer such that 2^p < n - 1 <= 2^(p+1), starting with a(1) = 1, a(2) = 2, and a(3) = 1.
1
1, 2, 1, 3, 6, 12, 24, 43, 68, 159, 318, 631, 1244, 2444, 4638, 8350, 13306, 31249, 62498, 124991, 249964, 499884, 999518, 1998110, 3992826, 7976984, 15904776, 31622086, 62494618, 121995928, 232079906, 417569970, 665554652, 1563189209, 3126378418, 6252756831, 12505513644
OFFSET
1,2
LINKS
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
Sequence in context: A357844 A104529 A095024 * A024741 A024961 A260666
KEYWORD
nonn
EXTENSIONS
Name edited by and more terms from Petros Hadjicostas, Nov 15 2019
STATUS
approved