OFFSET
0,2
COMMENTS
The clause "which yields a new number" is there to avoid a loop: if it is omitted, the sequence enters a cycle at 37 + 47 + ... + 257 + 263 = 6178, 6178 + 269 = 6187 = 23 * 269, 6187 - 269 = 6178. With the additional clause, the next step is to add the next larger prime 271.
One may ignore the initial a(0) = 0 and consider the sequence starting at a(1) = 2, this avoids asking about prime factors of the empty sum.
On the StackExchange web site it has been asked (a) whether any prime will eventually be removed from the sum, and (b) whether there are infinitely many "cyclic primes" that would yield a loop without the additional clause.
Up to 10^5 steps, the only cyclic primes are 269 occurring in a(58) = 6187 and 94793 occurring in a(9141) = 377844898.
LINKS
TheSimpliFier, Can we remove any prime number with this strange process?, math.StackExchange, July 8, 2019
EXAMPLE
The empty sum has nothing to remove, so we add the smallest prime to get a(1) = 2.
This is a prime so again we don't remove anything and add the next larger prime to get a(2) = 2 + 3 = 5.
This is again a prime so we add to the sum the next larger prime after the largest term 3, to get a(3) = 2 + 3 + 5 = 10.
Now 10 = 2 * 5, so we remove the primes 2 and 5 from the sum and get 3, then we add the next larger prime to get a(4) = 3 + 5 = 8.
Now 8 = 2^3 but there's no term 2 in the sum that could be removed, so we add the next larger prime to get a(5) = 3 + 5 + 7 = 15.
Now 15 = 3 * 5 so we remove terms 3 and 5 from the sum, and after adding the next larger prime get a(6) = 7 + 11 = 18.
MAPLE
R:= [0, 2]: S:= {2}: s:= 2:
for iter from 1 to 100 do
if not isprime(s) then
T:= select(p -> s mod p = 0, S);
S:= S minus T;
s:= s - convert(T, `+`);
fi;
p:= nextprime(max(S));
while member(s+p, R) do p:= nextprime(p) od:
S:= S union {p}; s:= s+p; R:= [op(R), s];
od:
R; # Robert Israel, Aug 28 2020
PROG
(PARI) A332198_vec(N, s=[2], n(s)=nextprime(s[#s]+1))={vector(N, i, #s>1 && s=setminus(s, factor(vecsum(s))[, 1]~); if(i<2, N=2, N==N=vecsum(s=concat(s, n(s))), printf("cyclic %d in a(%d)=%d, ", s[#s], i-1, N); N-=s[#s]-s[#s]=n(s), N))+print("least non-removed prime: ", s[1])}
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, Aug 28 2020
STATUS
approved