%I #24 Sep 20 2020 00:03:18
%S 0,2,5,10,8,15,18,31,48,67,90,119,126,163,204,247,262,315,374,424,438,
%T 509,582,661,744,802,899,971,1074,1181,1290,1360,1487,1618,1755,1894,
%U 2043,2194,2351,2514,2681,2854,3033,3214,3405,3598,3795,3971,4182,4364,4591,4820,5053,5129,5147,5398,5655,5918,6187
%N Start with the empty sum; if the sum is composite with prime factors occurring among the terms of the sum, remove these; then add to the terms of the sum the next larger prime which yields a new number; repeat.
%C 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.
%C 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.
%C 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.
%C Up to 10^5 steps, the only cyclic primes are 269 occurring in a(58) = 6187 and 94793 occurring in a(9141) = 377844898.
%H TheSimpliFier, <a href="https://math.stackexchange.com/questions/3286548/can-we-remove-any-prime-number-with-this-strange-process">Can we remove any prime number with this strange process?</a>, math.StackExchange, July 8, 2019
%e The empty sum has nothing to remove, so we add the smallest prime to get a(1) = 2.
%e This is a prime so again we don't remove anything and add the next larger prime to get a(2) = 2 + 3 = 5.
%e 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.
%e 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.
%e 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.
%e 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.
%p R:= [0,2]: S:= {2}: s:= 2:
%p for iter from 1 to 100 do
%p if not isprime(s) then
%p T:= select(p -> s mod p = 0, S);
%p S:= S minus T;
%p s:= s - convert(T,`+`);
%p fi;
%p p:= nextprime(max(S));
%p while member(s+p,R) do p:= nextprime(p) od:
%p S:= S union {p}; s:= s+p; R:= [op(R),s];
%p od:
%p R; # _Robert Israel_, Aug 28 2020
%o (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])}
%K nonn
%O 0,2
%A _M. F. Hasler_, Aug 28 2020
|