A055266 a(n) + a(n+1) is never prime; lexicographically earliest such sequence of distinct positive integers.
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
Examples
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.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
- M. F. Hasler, Prime sums from neighboring terms, OEIS wiki, Nov. 23, 2019
- Index entries for sequences that are permutations of the natural numbers
Programs
-
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
-
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 *)
-
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
Formula
Extensions
Corrected by Zak Seidov, Oct 21 2009
Name edited by M. F. Hasler, Nov 26 2019
Comments