Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #22 Sep 14 2020 05:45:36
%S 0,2,1,4,-2,6,8,-6,10,14,-20,12,18,-16,22,-12,20,-18,16,24,-10,28,-34,
%T 30,-26,32,-24,34,-4,40,-60,38,36,-56,44,-14,42,-48,26,54,-72,52,48,
%U -66,50,-42,46,-30,60,-90,62,-36,58,-52,64,-22,-8,74,-38,68,-54,66,-78,76,-70,82,-46
%N 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.
%C See A175499 for an equivalent sequence which sums to the smallest positive integer not yet created.
%e 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.
%e 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.
%e 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.
%e 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.
%t 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 *)
%Y Cf. A175499, A000040, A000217.
%K sign
%O 0,2
%A _Scott R. Shannon_, Sep 08 2020