The OEIS is supported by the many generous donors to the OEIS Foundation.

 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 59th year, we have over 358,000 sequences, and we’ve crossed 10,300 citations (which often say “discovered thanks to the OEIS”). Other ways to Give
 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A159559 Lexicographically first strictly increasing sequence starting a(2) = 3 with the property that a(n) is prime if and only if n is prime. 23
 3, 5, 6, 7, 8, 11, 12, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 29, 30, 32, 33, 37, 38, 39, 40, 42, 44, 47, 48, 53, 54, 55, 56, 57, 58, 59, 60, 62, 63, 67, 68, 71, 72, 74, 75, 79, 80, 81, 82, 84, 85, 89, 90, 91, 92, 93, 94, 97, 98, 101, 102, 104, 105, 106, 108, 109, 110, 111 (list; graph; refs; listen; history; text; internal format)
 OFFSET 2,1 COMMENTS a(n) is prime iff n is prime. LINKS Charles R Greathouse IV, Table of n, a(n) for n = 2..10000 Vladimir Shevelev, Several results on sequences which are similar to the positive integers, arXiv:0904.2101 [math.NT], 2009. FORMULA a(n+1) = min{m>a(n), m is prime}, if n+1 is prime; otherwise, a(n+1) = min{m>a(n), m is composite}. EXAMPLE For n = 6, since n is composite, a(6) is the smallest composite number greater than a(6-1) = a(5) = 7, so a(6) = 8. For n = 11, since n is prime, a(11) is the smallest prime number greater than a(11-1) = a(10) = 15, so a(12) = 17. - Michael B. Porter, Sep 04 2016 MAPLE A159559 := proc(n) option remember; if n = 2 then 3; else for a from procname(n-1)+1 do if isprime(n) and isprime(a) then RETURN(a) ; elif not isprime(n) and not isprime(a) then RETURN(a) ; fi; od: fi; end: seq(A159559(n), n=2..100) ; # R. J. Mathar, Jul 28 2009 MATHEMATICA a[2] = 3; a[n_] := a[n] = If[PrimeQ[n], NextPrime[a[n-1]], NestWhile[#+1&, a[n-1]+1, PrimeQ]]; Map[a, Range[2, 100]] (* Peter J. C. Moses, Sep 19 2013 *) PROG (PARI) nextcomposite(n)=if(n<4, return(4)); n=ceil(n); if(isprime(n), n+1, n) first(n)=my(v=vector(n)); v[2]=3; for(k=3, n, v[k]=if(isprime(k), nextprime(v[k-1]+1), nextcomposite(v[k-1]+1))); v[2..n] \\ Charles R Greathouse IV, Sep 21 2016 CROSSREFS Cf. A159698, A229019, A229132. Sequence in context: A253201 A139636 A219922 * A047583 A010906 A114309 Adjacent sequences: A159556 A159557 A159558 * A159560 A159561 A159562 KEYWORD nonn AUTHOR Vladimir Shevelev, Apr 15 2009, May 04 2009 EXTENSIONS More terms from R. J. Mathar, Jul 28 2009 STATUS approved

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

Last modified December 9 23:05 EST 2022. Contains 358710 sequences. (Running on oeis4.)