The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A255004 Lexicographically earliest permutation of positive integers such that a(a(n)+a(n+1)) is prime for all n. 4
 1, 2, 3, 4, 5, 6, 7, 8, 11, 9, 13, 10, 17, 12, 19, 14, 15, 16, 23, 29, 18, 31, 37, 20, 21, 22, 41, 24, 43, 25, 47, 26, 53, 27, 28, 30, 32, 33, 59, 34, 61, 35, 67, 36, 38, 39, 71, 40, 73, 42, 44, 79, 45, 46, 83, 48, 89, 97, 49, 50, 51, 101, 103, 52, 107, 54 (list; graph; refs; listen; history; text; internal format)
 OFFSET 1,2 COMMENTS This is the sequence V defined in the Comments on A255003. LINKS Alois P. Heinz, Table of n, a(n) for n = 1..10000 MAPLE N:= 100: # to get a(n) for n <= N maxprime:= 2: maxa:= 2: a[1]:= 1: a[2]:= 2: needprime:= {3}: for n from 3 to N do   if member(n, needprime) then      a[n]:= nextprime(maxprime);      maxprime:= a[n];   else      if isprime(maxa+1) and maxa+1<= maxprime then a[n]:= maxa+2      else a[n]:= maxa+1      fi;      maxa:= a[n];   fi;   needprime:= needprime union {a[n-1]+a[n]}; od: seq(a[n], n=1..N); # Robert Israel, Mar 26 2015 MATHEMATICA M = 100; maxprime = 2; maxa = 2; a[1] = 1; a[2] = 2; needprime = {3}; For[n = 3, n <= M, n++, If[MemberQ[needprime, n], a[n] = NextPrime[maxprime]; maxprime = a[n], If[PrimeQ[maxa+1] && maxa+1 <= maxprime, a[n] = maxa+2, a[n] = maxa+1]; maxa = a[n]]; needprime = needprime ~Union~ {a[n-1] + a[n]}]; Array[a, M] (* Jean-François Alcover, Mar 22 2019, after Robert Israel *) PROG (PARI) {a=vector(100, i, 1); u=[1]/* used numbers beyond u[1] */; for(n=2, #a, if( a[n] < 0, a[n]=u[1]; while(setsearch(u, a[n]++)||!isprime(a[n]), ), a[n]=u[1]; while(setsearch(u, a[n]++), )); u=setunion(u, [a[n]]); while( #u>1 && u[2]==u[1]+1, u=u[2..#u]); a[n]+a[n-1]>#a || a[a[n]+a[n-1]]=-1)} CROSSREFS Cf. A255003, A256210. For indices of primes see A256212. Sequence in context: A048334 A087027 A280770 * A257728 A329303 A330091 Adjacent sequences:  A255001 A255002 A255003 * A255005 A255006 A255007 KEYWORD nonn AUTHOR Eric Angelini and M. F. Hasler, Feb 11 2015 STATUS approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified April 4 20:53 EDT 2020. Contains 333229 sequences. (Running on oeis4.)