login
A334404
a(0)=0; for n>0, a(n) is an integer not previously seen such that the sum of all previous terms plus a(n) equals the smallest prime number not yet created by any previous sum.
0
0, 2, 1, 4, -2, 6, 8, -6, 10, 14, -20, 12, 18, -16, 22, -12, 20, -18, 16, 24, -10, 28, -34, 30, -26, 32, -24, 34, -4, 40, -60, 38, 36, -56, 44, -14, 42, -48, 26, 54, -72, 52, 48, -66, 50, -42, 46, -30, 60, -90, 62, -36, 58, -52, 64, -22, -8, 74, -38, 68, -54, 66, -78, 76, -70, 82, -46
OFFSET
0,2
COMMENTS
See A175499 for an equivalent sequence which sums to the smallest positive integer not yet created.
EXAMPLE
a(1) = 2 as the sum of all previous terms plus a(1) = 0 + 2 = 2, where 2 has not previously occurred in the sequence and the prime 2 has not been previously created.
a(2) = 1 as the sum of all previous terms plus a(2) = 0 + 2 + 1 = 3, where 1 has not previously occurred in the sequence and the prime 3 has not been previously created.
a(3) = 4 as the sum of all previous terms plus a(3) = 0 + 2 + 1 + 4 = 7, where 4 has not previously occurred in the sequence and the prime 7 has not been previously created. Note that the next smallest uncreated prime after a(2) is 5 but that would require a(3) = 2 which is not allowed as a(1) = 2.
a(4) = -2 as the sum of all previous terms plus a(4) = 0 + 2 + 1 + 4 - 2 = 5, where -2 has not previously occurred in the sequence and the prime 5 has not been previously created.
MATHEMATICA
Nest[Block[{k = 1, s = Total[#[[All, 1]] ], i = 1, p}, While[Nand[FreeQ[#[[All, -1]], Set[p, Prime@ i]], FreeQ[#[[All, 1]], p - s] ], i++]; While[Nand[FreeQ[#[[All, 1]], k], k + s == p], If[k < 0, Set[k, -k + 1], k *= -1]]; Append[#, {k, p}]] &, {{0, 0}}, 66][[All, 1]] (* Michael De Vlieger, Sep 11 2020 *)
CROSSREFS
KEYWORD
sign
AUTHOR
Scott R. Shannon, Sep 08 2020
STATUS
approved