login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) + a(n+1) is never prime; lexicographically earliest such sequence of distinct positive integers.
21

%I #39 Jan 24 2021 10:29:57

%S 1,3,5,4,2,6,8,7,9,11,10,12,13,14,16,17,15,18,20,19,21,23,22,24,25,26,

%T 28,27,29,31,32,30,33,35,34,36,38,37,39,41,40,42,43,44,46,45,47,48,50,

%U 49,51,53,52,54,56,55,57,58,59,60,61,62,63,65,64,66,67,68,70,71,69,72

%N a(n) + a(n+1) is never prime; lexicographically earliest such sequence of distinct positive integers.

%C See A253074 for an essentially identical sequence (with a proof that the sequence is a permutation).

%C Sequence A253074 is defined in the same way, but starting with 0. This happens to produce the same sequence from the next term on. This is the case (M,N) = (2,0) in the family of sequences where M consecutive terms yield N primes in their pairwise sums, see the wiki page for other examples. - _M. F. Hasler_, Nov 26 2019

%H Robert Israel, <a href="/A055266/b055266.txt">Table of n, a(n) for n = 1..10000</a>

%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

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F a(n) = A253074(n+1) (as long as A253074(1) = 0). - _M. F. Hasler_, Nov 26 2019

%e a(3) = 5 because 1 and 3 have already been used and both 3 + 2 = 5 and 3 + 4 = 7 are prime while 3 + 5 = 8 is not prime.

%p N:= 1000; # to get a[n] for n up to N

%p A:= {1};

%p a[1]:= 1;

%p for n from 2 to N do

%p mA:= max(A);

%p R:= {$1..mA} minus A;

%p for x in R do

%p if not isprime(a[n-1]+x) then

%p a[n]:= x;

%p break

%p fi

%p od:

%p if not assigned(a[n]) then

%p for x from mA+1 do

%p if not isprime(a[n-1]+x) then

%p a[n]:= x;

%p break

%p fi

%p od

%p fi;

%p A:= A union {x};

%p od:

%p seq(a[n],n=1..N); # _Robert Israel_, Jun 03 2014

%t f[ s_ ]:=Block[ {k=1,a=s[ [ -1 ] ]},While[ Or[ MemberQ[ s,k ],PrimeQ[ a+k ] ],k++ ];Append[ s,k ] ];Nest[ f,{1},121 ] (* _Zak Seidov_, Oct 21 2009 *)

%t a={1};z=Range[2,2002];z=Complement[z,a];While[Length[z]>1,If[!PrimeQ[z[[1]]+Last[a]],AppendTo[a,z[[1]]],If[!PrimeQ[z[[2]]+Last[a]],AppendTo[a,z[[2]]],AppendTo[a,z[[3]]]]];z=Complement[z,a]];Print[a] (* significantly faster *) (* _Vladimir Joseph Stephan Orlovsky_, May 03 2011 *)

%o (Haskell)

%o import Data.List (delete)

%o a055266 n = a055266_list !! (n-1)

%o a055266_list = 1 : f 1 [2..] where

%o f u vs = g vs where

%o g (w:ws) | a010051' (u + w) == 0 = w : f w (delete w vs)

%o | otherwise = g ws

%o -- _Reinhard Zumkeller_, Jan 14 2015

%o (PARI) v=[1]; n=1; while(n<100, if(!isprime(n+v[#v])&&!vecsearch(vecsort(v), n), v=concat(v, n); n=0); n++); v \\ _Derek Orr_, Jun 08 2015

%o (PARI) A055266_upto(n=99, u=1, U, a)={vector(n, n, n=u; while(bittest(U, n-u)|| isprime(a+n), n++); if(n>u, U+=1<<(n-u), U>>=-u+u+=valuation(U+2, 2)); a=n) + if(default(debug), print([u]))} \\ Optional args allow to tweak computation. If debug > 0, print least unused number at the end. - _M. F. Hasler_, Nov 25 2019

%Y Cf. A055265, A010051, A249920 (inverse), A203069, A253074.

%K easy,nonn

%O 1,2

%A _Henry Bottomley_, May 09 2000

%E Corrected by _Zak Seidov_, Oct 21 2009

%E Name edited by _M. F. Hasler_, Nov 26 2019