A121053 A sequence S describing the position of its prime terms.
2, 3, 5, 1, 7, 8, 11, 13, 10, 17, 19, 14, 23, 29, 16, 31, 37, 20, 41, 43, 22, 47, 53, 25, 59, 27, 61, 30, 67, 71, 73, 33, 79, 35, 83, 38, 89, 97, 40, 101, 103, 44, 107, 109, 46, 113, 127, 49, 131, 51, 137, 54, 139, 149, 56, 151, 58, 157, 163, 62, 167, 173, 64, 179, 66, 181, 191, 69, 193, 72, 197, 199, 211, 75, 223, 77, 227, 80, 229
Offset: 1
References
- N. J. A. Sloane, The Remarkable Sequences of Éric Angelini, MS in preparation, December 2024.
Links
- N. J. A. Sloane, Table of n, a(n) for n = 1..20000 [First 1000 terms from Kerry Mitchell]
- Eric Angelini, A sequence describing the position of its prime terms, Blog Post, August 2006.
- E. Angelini, A sequence describing the position of its prime terms [Cached copy, with permission]
- N. J. A. Sloane, "A Handbook of Integer Sequences" Fifty Years Later, arXiv:2301.03149 [math.NT], 2023, p. 9.
- N. J. A. Sloane, A Nasty Surprise in a Sequence and Other OEIS Stories, Experimental Mathematics Seminar, Rutgers University, Oct 10 2024, Youtube video; Slides [Mentions this sequence]
Crossrefs
Programs
-
Maple
chi := proc(n) if n <= 3 then 0 else n - numtheory:-pi(n) - 1; fi; end; # A065855, number of composites <= n A002808 := proc(n) option remember ; local a ; if n = 1 then 4; else for a from procname(n-1)+1 do if not isprime(a) then return a; end if; end do ; end if; end proc; A121053 := proc(n) local init,t1; init := [2,3,5,1,7]; if n<=5 then return(init[n]); fi; if isprime(n) or (not isprime(n) and ((chi(n) mod 2) = 1)) then ithprime(floor((n+numtheory:-pi(n))/2)); else t1 := chi(n); A002808(t1+1); fi; end; [seq(A121053(n),n=1..120)]; # N. J. A. Sloane, Nov 14 2024
-
Mathematica
a[1]=2; a[2]=3; a[3]=5; a[4]=1; a[n_ /; PrimeQ[n] || !PrimeQ[n] && EvenQ[n+PrimePi[n]]] := Prime[Floor[(n+PrimePi[n])/2]]; a[n_ /; !PrimeQ[n] && OddQ[n+PrimePi[n]]] := If[!PrimeQ[n+1], n+1, n+2]; Table[a[n], {n, 1, 40}] (* Jean-François Alcover, Mar 21 2011, based on Dean Hickerson's formulas *)
-
Python
from sympy import isprime, prime, primepi, composite, compositepi def a(n): return [2, 3, 5, 1, 7][n-1] if n < 6 else prime(n+primepi(n)>>1) if isprime(n) or (c:=compositepi(n))&1 else composite(c+1) print([a(n) for n in range(1, 81)]) # Michael S. Branicky, Nov 29 2024
-
Python
# faster for initial segment of sequence from sympy import isprime, sieve from itertools import count, islice def nextcomposite(n): return next(k for k in count(n+1) if k not in sieve) def agen(): # generator of terms alst, chin, pin, nextc = [2, 3, 5, 1, 7], 1, 3, 6 yield from alst for n in count(6): if isprimen:=n < nextc: pin += 1 else: chin, nextc = chin + 1, nextcomposite(nextc) yield sieve[(n+pin)>>1] if isprimen or chin&1 else nextc print(list(islice(agen(), 80))) # Michael S. Branicky, Nov 29 2024
Comments