OFFSET
0,3
COMMENTS
That is, there are 7 primes, counted with multiplicity, among the 15 pairwise sums of any 6 consecutive terms.
Conjectured to be a permutation of the nonnegative integers. The restriction to [1,oo) is then a permutation of the positive integers with the same property, but not the smallest one which is A329576 = (1, 2, 3, 4, 5, 8, 11, ...).
For n > 5, a(n) is the smallest number not used earlier such that the set a(n) + {a(n-5}, ..., a(n-1)} has the same number of primes as a(n-6) + {a(n-5), ..., a(n-1)}. Such a number always exists, by definition of the sequence. (If it would not exist for a given n, this means the term a(n-1) (or earlier) "was wrong and must be corrected", so to say. Of course this only refers to an incorrect computation.)
LINKS
Éric Angelini, Prime sums from neighbouring terms, SeqFan list, Nov 11 2019.
M. F. Hasler, Prime sums from neighboring terms, OEIS wiki, Nov. 23, 2019.
EXAMPLE
Using the smallest possible 5 initial terms a(0..4) = (0, 1, 2, 3, 4), we have a total of 6 primes among the pairwise sums, namely 0+2, 0+3, 1+2, 1+4, 2+3 and 3+4. To satisfy the definition for n = 0, the next term a(5) must give exactly one more prime when added to these 5 initial terms. The smallest number with this property is 6, but this choice of a(5) would make it impossible to find a suitable a(7): Indeed, for n = 1 we must consider the pairwise sums of (1, 2, 3, 4, a(5), a(6)). If we had (1, 2, 3, 4, 6, a(6)), the first 5 terms would give 5 prime sums 1+2, 1+4, 1+6, 2+3 and 3+4. Then a(6) should give two more prime sums, which is easily possible, either with even a(6) such that 1+a(6) and 3+a(6) are prime, or odd a(6) such that two among {2, 4, 6} + a(6) are prime. Thereafter, for n = 2, we drop the 1 and include a(7) instead, which must produce the same number of prime sums when added to {2, 3, 4, 6, a(6)} as was the case for 1. For even a(6) this was 4 (1+2, 1+4, 1+6 and 1+a(6)), which is impossible to achieve with a(7) > 1, since 2+x, 4+x and 6+x can't be all prime for x > 1. For odd a(6) it is 3 (1+2, 1+4 and 1+6), which is also impossible as well for odd a(7) (same reason as before) as for even a(7) (since only 3 and a(6) are odd and can give a prime sum).
This shows that we can't take a(5) equal to 6, and must consider the next larger possibility, which is a(5) = 8 (with prime sum 3+8 = 11, while 7 would give more than one, 0+7 and 4+7). Now we find that the smallest possible a(6) = 5 yields a solution and all subsequent terms can also be chosen greedily.
PROG
(PARI) {A329567(n, show=1, o=0, N=7, M=5, X=[[4, 6]], p=[], u=o, U)=for(n=o, n-1, show>0&& print1(o", "); show<0&& listput(L, o); U+=1<<(o-u); U>>=-u+u+=valuation(U+1, 2); p=concat(if(#p>=M, p[^1], p), o); my(c=N-sum(i=2, #p, sum(j=1, i-1, isprime(p[i]+p[j])))); if(#p<M&&sum(i=1, #p, isprime(p[i]+u))<=c, o=u)|| for(k=u, oo, bittest(U, k-u)|| sum(i=1, #p, isprime(p[i]+k))!=c|| setsearch(X, [n, k])|| [o=k, break])); show&&print([u]); o} \\ optional args: show=1: print a(o..n-1), show=-1: append them on global list L, in both cases print [least unused number] at the end. See the wiki page for a function S() which returns a vector: a(0..n-1) = S(7, 6; 0).
CROSSREFS
Cf. related sequences with N prime sums using M consecutive terms, labeled (N,M): A329425 (6,5), A329566 (6,6), A329449 (4,4), A329456 (4,5), A329454 & A329416 (3,4), A329455 (3,5), A329411 (2,3), A329452 (2,4), A329453 (2,5), A329333 (1,3), A128280 & A055265 (1,2); A055266 & A253074 (0,2), A329405 & A329450 (0,3), A329406 - A329416: (1,4) ... (2,10).
KEYWORD
nonn
AUTHOR
M. F. Hasler, Feb 09 2020
STATUS
approved