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”).

A055266
a(n) + a(n+1) is never prime; lexicographically earliest such sequence of distinct positive integers.
21
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, 28, 27, 29, 31, 32, 30, 33, 35, 34, 36, 38, 37, 39, 41, 40, 42, 43, 44, 46, 45, 47, 48, 50, 49, 51, 53, 52, 54, 56, 55, 57, 58, 59, 60, 61, 62, 63, 65, 64, 66, 67, 68, 70, 71, 69, 72
OFFSET
1,2
COMMENTS
See A253074 for an essentially identical sequence (with a proof that the sequence is a permutation).
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
FORMULA
a(n) = A253074(n+1) (as long as A253074(1) = 0). - M. F. Hasler, Nov 26 2019
EXAMPLE
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.
MAPLE
N:= 1000; # to get a[n] for n up to N
A:= {1};
a[1]:= 1;
for n from 2 to N do
mA:= max(A);
R:= {$1..mA} minus A;
for x in R do
if not isprime(a[n-1]+x) then
a[n]:= x;
break
fi
od:
if not assigned(a[n]) then
for x from mA+1 do
if not isprime(a[n-1]+x) then
a[n]:= x;
break
fi
od
fi;
A:= A union {x};
od:
seq(a[n], n=1..N); # Robert Israel, Jun 03 2014
MATHEMATICA
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 *)
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 *)
PROG
(Haskell)
import Data.List (delete)
a055266 n = a055266_list !! (n-1)
a055266_list = 1 : f 1 [2..] where
f u vs = g vs where
g (w:ws) | a010051' (u + w) == 0 = w : f w (delete w vs)
| otherwise = g ws
-- Reinhard Zumkeller, Jan 14 2015
(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
(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
CROSSREFS
Sequence in context: A349376 A134892 A253074 * A338843 A075077 A196771
KEYWORD
easy,nonn
AUTHOR
Henry Bottomley, May 09 2000
EXTENSIONS
Corrected by Zak Seidov, Oct 21 2009
Name edited by M. F. Hasler, Nov 26 2019
STATUS
approved