cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A161185 First column of a table of all primes sorted by recursive look-up depending on the primality of their indices.

Original entry on oeis.org

2, 3, 7, 11, 17, 19, 29, 31, 37, 41, 43, 47, 53, 67, 71, 73, 79, 83, 89, 97, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 181, 191, 193, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 271, 277, 281, 283, 293, 307, 311, 313, 317, 337, 347, 349
Offset: 1

Views

Author

Daniel Tisdale, Jun 05 2009

Keywords

Comments

We start from two lists of primes according to whether their indices are prime or nonprime, the first list being A007821, the second A006450:
2,7,13,19,23,29,37,43,47,53,61,71,73,79,89,..
3,5,11,17,31,41,59,67,83,109,127,157,179,191,..
We construct rows of an intermediate table by transversing this double list, basically reading a number, then using this number as an index into the other list, reading the prime there, using it again as an index into the original list etc, alternating between the two lists.
A new row is started from the smallest prime not contained in any earlier row (the "generator" of this row). The first row starts with 2, takes the 2nd entry of the other list (which is 5), takes the 5th entry from the original list (which is 23), then the 23rd entry of the other list etc. The 2nd row starts with 3 (the smallest prime not in the first row), takes the 3rd entry from the first list (which is 13), then the 13th entry from the 2nd list (which is 179), etc.
By construction, the table contains each prime exactly once. The first column with the generators defines the sequence.

Examples

			The table with the generator in the first column and followup primes in the same row starts:
  2,5,23,431,3821,...
  3,13,179,1439,...
  7,59,419,...
  11,61,1847,...
  17,101,3943,...
  19,331,2833,...
  29,599,5507,...
  31,197,9739,...
  37,919,8861,...
  41,269,...
  43,1153,...
  47,1297,...
		

Crossrefs

Cf. A141436.

Programs

  • PARI
    lista(nn) = my(v = primes(nn), vp = select(x->isprime(primepi(x)), v), vc = setminus(v, vp), list = List()); while (#v, my(p=v[1], q); listput(list, p); v = setminus(v, [p]); my(ok = 1); while(ok, if (vecsearch(vp, p), vx=vc; vy=vp, vx=vp; vy=vc); if (p > #vx, ok = 0, q = vx[p]; v = setminus(v, [q]); if (q > #vy, ok = 0, q = vy[q]; v = setminus(v, [q]); p = q;);););); Vec(list); \\ Michel Marcus, Oct 31 2022

Extensions

Edited and extended by R. J. Mathar, Jun 23 2009
More terms from Michel Marcus, Oct 31 2022