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-5 of 5 results.

A339022 a(n) is the floor of the average distance among first n primes.

Original entry on oeis.org

1, 2, 2, 4, 5, 6, 7, 9, 10, 12, 13, 15, 16, 18, 19, 21, 23, 24, 26, 27, 29, 30, 32, 34, 36, 38, 39, 41, 42, 44, 46, 48, 50, 52, 54, 56, 57, 59, 61, 63, 65, 67, 69, 71, 72, 74, 77, 79, 81, 83, 85, 86, 88, 90, 92, 95, 96, 98, 100, 102, 104, 106, 108
Offset: 2

Views

Author

Andres Cicuttin, Nov 19 2020

Keywords

Comments

Is the limit of a(n)/n finite?

Crossrefs

Cf. A338869 (Shortest most frequent distance among first n primes).

Programs

  • Mathematica
    nmax=64;
    Table[Total[Flatten[Table[Table[Prime[k] - Prime[j], {j, 1, k - 1}], {k, 2, n}]]]/(n*(n - 1)/2), {n, 2, nmax}]//Floor

Formula

a(n) = floor((2/(n*(n-1)))*Sum_{j=2..n} Sum_{i=1..j-1} (prime(j) - prime(i))).

A332094 Numerator of the average distance among first n primes.

Original entry on oeis.org

1, 2, 17, 22, 27, 142, 31, 9, 97, 666, 83, 604, 1529, 1906, 791, 367, 3533, 4238, 5019, 584, 617, 7822, 8995, 518, 473, 13342, 1663, 8324, 3689, 20662, 23003, 532, 1655, 31074, 541, 6218, 2145, 44354, 48187, 2613, 18805, 20330, 65651, 356, 15083, 80894, 28979, 23293
Offset: 2

Views

Author

Andres Cicuttin, Nov 20 2020

Keywords

Crossrefs

Cf. A336814 (denominator), A338869, A339022, A062020.

Programs

  • Mathematica
    nmax=64;
    Table[Total[Flatten[Table[Table[Prime[k] - Prime[j], {j, 1, k - 1}], {k, 2, n}]]]/(n*(n - 1)/2), {n, 2, nmax}]//Numerator
  • PARI
    lista(nn) = {my(vp = primes(nn)); vector(nn-1, k, k++; numerator((2/(k*(k-1))*sum(j=2, k, sum(i=1, j-1, vp[j] - vp[i])))));} \\ Michel Marcus, Nov 21 2020

Formula

a(n) = numerator((2/(n*(n-1)))*Sum_{j=2..n} Sum_{i=1..j-1} (prime(j) - prime(i))).

A336814 Denominator of the average distance among first n primes.

Original entry on oeis.org

1, 1, 6, 5, 5, 21, 4, 1, 9, 55, 6, 39, 91, 105, 40, 17, 153, 171, 190, 21, 21, 253, 276, 15, 13, 351, 42, 203, 87, 465, 496, 11, 33, 595, 10, 111, 37, 741, 780, 41, 287, 301, 946, 5, 207, 1081, 376, 294, 35, 425, 1326, 689, 477, 33, 1540, 133, 551, 1711, 1770, 915, 1891, 1953, 224
Offset: 2

Views

Author

Andres Cicuttin, Nov 21 2020

Keywords

Crossrefs

Cf. A332094 (numerator), A338869, A339022, A062020.

Programs

  • Mathematica
    nmax=64;
    Table[Total[Flatten[Table[Table[Prime[k] - Prime[j], {j, 1, k - 1}], {k, 2, n}]]]/(n*(n - 1)/2), {n, 2, nmax}]//Denominator
    (* Also *)
    denavepdist[n_]:=Module[{pset,p2s,diffp2s},
    pset=Prime[Range[n]];
    p2s=Subsets[pset,{2}];
    diffp2s=Map[Differences,p2s]//Flatten//Tally;
    Sum[diffp2s[[j]][[1]]*diffp2s[[j]][[2]],{j,1,Length[diffp2s]}]/Length[p2s]//Denominator//Return];
    Table[denavepdist[n],{n,2,2^6}]

Formula

a(n) = denominator((2/(n*(n-1)))*Sum_{j=2..n} Sum_{i=1..j-1} (prime(j) - prime(i))).

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

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-5 of 5 results.