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.

A343118 Length of the longest sequence of equidistant primes among the first n primes.

Original entry on oeis.org

2, 2, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
Offset: 2

Views

Author

Andres Cicuttin, Apr 05 2021

Keywords

Comments

This sequence is unbounded as stated by the Green-Tao theorem.

Examples

			For the first 2 primes {2,3}, the sequence is itself a list of two equidistant primes, so a(2) = 2.
For the first 3 primes {2,3,5}, there is at most two equidistant primes, so a(3) = 2.
For the first 4 primes {2,3,5,7}, the subsequence {3,5,7} is the longest subsequence with 3 equidistant primes, so a(4) = 3.
For the first 10 primes {2,3,5,7,11,13,17,19,23,29}, the subsequence {5,11,17,23,29} is the longest subsequence with 5 equidistant primes, so a(10) = 5.
		

Crossrefs

Programs

  • Mathematica
    nmax = 128; (* Last n *)
    maxlen = 11 ; (* Maximum exploratory length of sequences of equidistant primes. "maxlen" must be larger than the maximum term obtained with "nmax" *)
    (* a[n,p,s] returns the sequence of "s" equidistant primes with period "p" and last prime prime(n) if it exists, otherwise it returns {} *)
    a[n_, period_, seqlen_] := Module[{tab, test},
    (* Building sequences of equidistant numbers ending with prime(n) *)
      tab = Table[Prime[n] - k*period, {k, 0, seqlen - 1}];
    (* Checking if all elements are primes and greater than 2 *)
      test = (And @@ PrimeQ@tab) && (And @@ Map[(# > 2 &), tab]);
      Return[If[test, tab, {}]]];
    atab = {}; aterms = {};
    (* For every n, exploring all sequences of equidistant primes among the first n primes with n > 2 *)
    Do[
      Do[Do[
        If[a[n, period, seqlen] != {}, AppendTo[atab, seqlen]]
        , {period, 2, Ceiling[Prime[n]/(seqlen - 1)], 2}]
       , {seqlen, 2, maxlen}];
    (* Saving the pairs {n, corresponding maximum lengths} *)
      AppendTo[aterms, {n, Max[atab]}]
      , {n, 3, nmax}];
    (* Prepending the first term corresponding to the trivial case of first two primes {2,3} *)
    Join[{2}, (Transpose[aterms][[2]])]

Formula

a(A000720(A005115(n))) = n. - Rémy Sigrist, Apr 15 2021