login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A049923
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.
3
1, 3, 2, 3, 6, 12, 24, 39, 51, 138, 276, 543, 1059, 2019, 3633, 5790, 7809, 21405, 42810, 85611, 171195, 342291, 684177, 1366878, 2729985, 5444355, 10824504, 21392328, 41760069, 79442661, 142937349, 227824365, 307267026, 842358414
OFFSET
1,2
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^ceil(log(n-1)/log(2))]; sa += va[n]; ); va; } \\ Petros Hadjicostas, Apr 26 2020 (with nn > 2)
CROSSREFS
Cf. A049922 (similar, but with minus a(m/2)), A049970 (similar, but with plus a(m/2)), A049971 (similar, but with plus a(m)).
Sequence in context: A058533 A215413 A058644 * A184881 A007054 A377920
KEYWORD
nonn
EXTENSIONS
Name edited by Petros Hadjicostas, Apr 26 2020
STATUS
approved