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”).

A049971
a(n) = a(1) + a(2) + ... + a(n-1) + a(m) for n >= 4, where m = 2*n - 2 - 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) = 3, and a(3) = 2.
4
1, 3, 2, 9, 24, 42, 90, 213, 597, 984, 1974, 3981, 8133, 17037, 37071, 87198, 244557, 401919, 803844, 1607721, 3215613, 6431997, 12866991, 25747038, 51564237, 103443195, 208092192, 421008660, 861332361, 1800360879, 3918287223, 9215926665, 25847419116, 42478911570, 84957823146
OFFSET
1,2
LINKS
EXAMPLE
a(5) = a(1) + a(2) + a(3) + a(4) + a(m) = 1 + 3 + 2 + 9 + a(m) = 15 + a(m). where m = 2*n - 2 - 2^(p+1) and 2^p < n - 1 = 4 <= 2^(p+1). We have p = 1 giving m = 2*5 - 2 - 4 = 4. As a(m) = a(4) = 9, we have a(5) = 15 + 9 = 24. - David A. Corneth, Apr 26 2020
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, 3, 2][n], s(n - 1) + a(-2^ceil(log[2](n - 1)) + 2*n - 2)):
end proc:
seq(a(n), n = 1..40); # Petros Hadjicostas, Apr 25 2020
# Alternative, uses A062050:
a := proc(n) option remember; if n < 4 then [1, 3, 2][n] else
add(a(i), i = 1..n-1 ) + a(2*A062050(n-2)) fi end:
seq(a(n), n = 1..35); # Peter Luschny, Aug 06 2021
MATHEMATICA
a[1] = 1; a[2] = 3; a[3] = 2; a[n_] := a[n] = Sum[a[k], {k, 1, n - 1}] + a[2*n - 2 - 2^Floor[1 + Log[2, n - 2]]]; Table[a[n], {n, 1, 30}] (* Vaclav Kotesovec, Apr 26 2020 *)
PROG
(PARI) lista(nn) = { my(va = vector(nn)); va[1] = 1; va[2] = 3; va[3] = 2; my(sa = vecsum(va)); for (n=4, nn, va[n] = sa + va[2*n - 2 - 2*2^logint(n-2, 2)]; sa += va[n]; ); va; } \\ Michel Marcus, Apr 26 2020 (with nn > 2)
(PARI) first(n) = {n = max(n, 3); my(res = vector(n), s = 6, p = 1); res[1] = 1; res[2] = 3; res[3] = 2; for(i = 4, n, if(i - 1 > 1 << (p + 1), p++); res[i] = s + res[2*i-2-2^(p+1)]; s += res[i]) ; res} \\ David A. Corneth, Apr 26 2020
CROSSREFS
Cf. A049922 (similar, but with minus a(m/2)), A049923 (similar, but with minus a(m)), A049970 (similar, but with plus a(m/2)).
Sequence in context: A234840 A234743 A284989 * A234748 A156528 A234744
KEYWORD
nonn,easy
EXTENSIONS
Name edited by Petros Hadjicostas, Apr 25 2020
More terms from David A. Corneth, Apr 26 2020
STATUS
approved