%I #20 Apr 17 2022 03:55:19
%S 0,1,2,3,4,5,8,9,10,14,33,15,20,27,26,11,32,16,41,21,57,116,22,51,38,
%T 23,50,63,86,6,17,24,77,65,18,13,114,25,36,28,35,43,12,31,61,66,40,19,
%U 47,42,90,241,7,52,37,34,45,30,55,49,394,58,73,39,48,64,109,115
%N For every n >= 0, exactly 10 sums are prime among a(n+i) + a(n+j), 0 <= i < j < 7; lexicographically earliest such sequence of distinct nonnegative numbers.
%C That is, there are 10 primes, counted with multiplicity, among the 21 pairwise sums of any 7 consecutive terms.
%C Conjectured to be a permutation of the nonnegative integers.
%C If it is, then the restriction to [1..oo) is a permutation of the positive integers, but maybe not the lexicographically earliest one with this property.
%C This is the first example of a sequence of this type for which the greedy choice of a(n) is frequently incorrect beyond the initial terms, see Examples.
%H M. F. Hasler, <a href="/wiki/User:M._F._Hasler/Prime_sums_from_neighboring_terms">Prime sums from neighboring terms</a>, OEIS Wiki, Nov. 23, 2019, updated Feb. 2020.
%e At the beginning of the sequence, we must avoid the choice of 6 or 7 for a(6): both appear to be possible at first sight, giving exactly 10 prime sums with n = 0 in the definition, but then make it impossible to find a successor term a(7) for which the definition is satisfied with n = 1.
%e The same happens again for a(37) and a(58), where the apparently possible value 19 resp. 46 must be avoided.
%o (PARI) {A329574(n, show=0, o=0, N=10, M=6, X=[[6,6],[6,7],[37,19],[58,46]], p=[], u=o, U)=for(n=o+1, n, 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])))); for(k=u, oo, bittest(U, k-u)|| min(c-#[0|x<-p, isprime(x+k)], #p>=M)|| 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. Parameters N, M, o, ... allow getting other variants, see the wiki page for more.
%Y Cf. A055265, A128280 (1 prime from 2 terms), A329333 (1 prime from 3 terms), A329405, ..., A329416 (N primes from M terms >= 1), A329425, A329449, ..., A329581 (N primes from M terms >= 0).
%K nonn
%O 0,3
%A _M. F. Hasler_, Feb 10 2020
|