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