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.

Showing 1-2 of 2 results.

A338869 Shortest most frequent distance among first n primes.

Original entry on oeis.org

1, 1, 2, 2, 2, 2, 2, 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, 30, 30, 30, 30, 6, 30, 6, 6, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30
Offset: 2

Views

Author

Andres Cicuttin, Nov 13 2020

Keywords

Comments

Conjecture: Shortest most frequent distance among first n primes is a primorial number (A002110) for n>1.
This sequence is quite related to A338238 with which it shares many terms.
The corresponding frequencies of the most frequent distances among n first primes are in A283371.

Examples

			For n = 2, the distance between the first two primes 2 and 3 is 1, so the only possible distance is also the most frequent one, then a(2) = 1.
For n = 3, the distances between the first three primes 2, 3 and 5 are 1 = 3 - 2, 3 = 5 - 2, and 2 = 5 - 3, so all three distances are different, have the same frequency, and the shortest among them is 1, then a(3) = 1.
For n = 4, the five different distances between the first four primes 2, 3, 5 and 7 are 1 = 3 - 2, 2 = 5 - 3 = 7 - 5, 3 = 7 - 4 , 4 = 7 - 3 and 5 = 7 - 2, then a(3) = 2 because 2 is the most common distance (two cases) compared with the other distances which appear only once.
For n = 32, the most frequent distances are 30 and 6, and both appear with the same frequency (19 cases), then a(32) = 6 because 6 is the shortest between 30 and 6.
		

Crossrefs

Programs

  • Mathematica
    a[n_]:=Module[{pset, p2s,diffp2s,sd,sdgb,sdgbst},
    pset=Prime[Range[n]]; (* First n primes *)
    p2s=Subsets[pset,{2}]; (* All possible pairs of primes *)
    (* Compute all possible distances and the corresponding frequencies *)
    diffp2s=Map[Differences,p2s]//Flatten//Tally ;
    (* Sort pairs {distance, frequency} by decreasing frequency *)
    sd=Sort[diffp2s,#1[[2]]>#2[[2]]&];
    (* Gather pairs {dist, freq} with same maximum frequency *)
    sdgb=GatherBy[sd,sd[[1]][[2]]==#[[2]] &];
    (* Sort selected pairs {dist, freq} with maximum frequency according to increasing distance *)
    sdgbst=Sort[sdgb[[1]],#1[[1]]<#2[[1]]&];
    (* Finally select and return the minimum distance among those with same maximum frequency *)
    sdgbst[[1]][[1]] //Return];
    Table[a[n],{n,2,100}]

A343122 Consider the longest arithmetic progressions of primes from among the first n primes; a(n) is the smallest constant difference of these arithmetic progressions.

Original entry on oeis.org

1, 1, 2, 2, 2, 2, 2, 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, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30
Offset: 2

Views

Author

Andres Cicuttin, Apr 05 2021

Keywords

Comments

It seems that most terms are primorials (see comments in A338869 and A338238).

Examples

			For n=2, the first two primes are 2 and 3, the only subsequence of equidistant primes. The constant difference is 1, so a(2) = 1.
For n=3, there are three sequences of equidistant primes: {2,3} with constant difference 1, {3,5} with difference 2, and {2,5} with difference 3, so a(3) = 1 because 1 is the smallest constant difference among the three longest sequences.
		

Crossrefs

Cf. A338869, A338238, A002110 (Primorials), A343118, A033188.

Programs

  • Mathematica
    nmax=100; (* Last n *)
    maxlen=11 ; (* Maximum exploratory length of sequences of equidistant primes *)
    (* 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 > 3 *)
    Do[
    Do[Do[
    If[a[n,period,seqlen]!={},AppendTo[atab,{seqlen,period}]]
    ,{period,2,Ceiling[Prime[n]/(seqlen-1)],2}]
    ,{seqlen,2,maxlen}];
    (* "longmax" is the length of the longest sequences *)
    longmax=Sort[atab,#1[[1]]>#2[[1]]&][[1]][[1]];
    (* Selecting the elements corresponding to the longest sequences *)
    atab=Select[atab,#[[1]]==longmax&];
    (* Saving the pairs {n, corresponding minimum periods} *)
    AppendTo[aterms,{n,Min[Transpose[atab][[2]]]}]
    ,{n,4,nmax}];
    (* Prepending the first two terms corresponding to the simple cases of first primes {2,3} and {2,3,5} *)
    Join[{1,1},(Transpose[aterms][[2]])]
Showing 1-2 of 2 results.