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

A031131 Difference between n-th prime and (n+2)-nd prime.

Original entry on oeis.org

3, 4, 6, 6, 6, 6, 6, 10, 8, 8, 10, 6, 6, 10, 12, 8, 8, 10, 6, 8, 10, 10, 14, 12, 6, 6, 6, 6, 18, 18, 10, 8, 12, 12, 8, 12, 10, 10, 12, 8, 12, 12, 6, 6, 14, 24, 16, 6, 6, 10, 8, 12, 16, 12, 12, 8, 8, 10, 6, 12, 24, 18, 6, 6, 18, 20, 16, 12, 6, 10, 14, 14, 12, 10, 10, 14, 12, 12, 18, 12, 12, 12
Offset: 1

Views

Author

Keywords

Comments

Distance between the pair of primes adjacent to the (n+1)-st prime. - Lekraj Beedassy, Oct 01 2004 [Typo corrected by Zak Seidov, Feb 22 2009]
A031131(A261525(n)) = 2*n and A031131(m) != 2*n for m < A261525(n). - Reinhard Zumkeller, Aug 23 2015
The Polymath project 8b proved that a(n) <= 395106 infinitely often (their published paper contains the slightly weaker bound a(n) <= 398130 infinitely often). - Charles R Greathouse IV, Jul 22 2016

Examples

			a(10)=8 because the 10th prime=29 is followed by primes 31 and 37, and 37 - 29 = 8.
		

Crossrefs

Sum of consecutive terms of A001223.
Cf. A075527 (allowing 1 to be prime).
First differences of A001043.

Programs

  • Haskell
    a031131 n = a031131_list !! (n-1)
    a031131_list = zipWith (-) (drop 2 a000040_list) a000040_list
    -- Reinhard Zumkeller, Dec 19 2013
  • Magma
    [NthPrime(n+2)-NthPrime(n): n in [1..100] ]; // Vincenzo Librandi, Apr 11 2011
    
  • Maple
    P:= select(isprime, [2,seq(2*i+1,i=1..1000)]):
    P[3..-1] - P[1..-3]; # Robert Israel, Jan 25 2015
  • Mathematica
    Differences[lst_]:=Drop[lst,2]-Drop[lst,-2]; Differences[Prime[Range[123]]] (* Vladimir Joseph Stephan Orlovsky, Aug 13 2009 *)
    Map[#3 - #1 & @@ # &, Partition[Prime@ Range[84], 3, 1]] (* Michael De Vlieger, Dec 17 2017 *)
  • MuPAD
    ithprime(i+2)-ithprime(i) $ i = 1..65 // Zerinvary Lajos, Feb 26 2007
    
  • PARI
    a(n)=my(p=prime(n));nextprime(nextprime(p+1)+1)-p \\ Charles R Greathouse IV, Jul 01 2013
    
  • Sage
    BB = primes_first_n(67)
    L = []
    for i in range(65):
        L.append(BB[2+i]-BB[i])
    L
    # Zerinvary Lajos, May 14 2007
    

Formula

a(n) = A001223(n) + A001223(n-1). - Lior Manor, Jan 19 2005
a(n) = A000040(n+2) - A000040(n).
a(n) = 2*A052288(n-1) for n>1. - Hugo Pfoertner, Apr 16 2025

Extensions

Corrected by T. D. Noe, Sep 11 2008
Edited by N. J. A. Sloane, Sep 18 2008, at the suggestion of T. D. Noe

A031133 Lower prime of a record difference between it and the second prime after it.

Original entry on oeis.org

2, 3, 5, 19, 47, 83, 109, 199, 1123, 1321, 2161, 2477, 5591, 9551, 14087, 19603, 19609, 31393, 31397, 38461, 58789, 155893, 360653, 370247, 396733, 1357193, 1561891, 4652317, 8917463, 20831299, 38089217, 70396343, 72546143, 102765577
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    lst = {}; {p, q, r} = {1, 2, 3}; d = 0; Do[{p, q, r} = {q, r, Prime@n}; If[r - p > d, d = r - p; AppendTo[lst, {p, r}]; Print[{p, r-p, r}]], {n, 8050000}]; First /@ lst (* Robert G. Wilson v, May 17 2006 *)
  • PARI
    gap=0;p=2;q=3;forprime(r=5,1e9,if(r-p>gap,gap=r-p;print1(p", ")); p=q;q=r) \\ Charles R Greathouse IV, Mar 06 2013

Formula

Extensions

Extended (and first term added) by Patrick De Geest, Oct 15 2000
Further extended by Jud McCranie, Jan 03 2001
a(34)-a(52) from Jon E. Schoenfield, Sep 02 2006
a(53)-a(55) added by Dmitry Kamenetsky, Jul 28 2008
a(55) corrected, a(56)-a(62) added by Dmitry Petukhov, Sep 20 2015
a(63)-a(67) added by Vladimir Chirkov and Natalia Makarova, Sep 24 2015, Sep 29 2015

A031134 Upper prime of a record difference between it and the second prime before it.

Original entry on oeis.org

5, 7, 11, 29, 59, 97, 127, 223, 1151, 1361, 2203, 2521, 5639, 9601, 14143, 19661, 19681, 31469, 31477, 38543, 58889, 156007, 360769, 370373, 396871, 1357333, 1562051, 4652507, 8917663, 20831533, 38089453, 70396589, 72546391, 102765847
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    lst = {}; {p, q, r} = {1, 2, 3}; d = 0; Do[{p, q, r} = {q, r, Prime@n}; If[r - p > d, d = r - p; AppendTo[lst, {p, r}]; Print[{p, r-p, r}]], {n, 8050000}]; Last /@ lst (* Robert G. Wilson v, May 17 2006 *)

Formula

Extensions

Extended (and first term added) by Patrick De Geest, Oct 15 2000
Corrected and extended by Jud McCranie, Jan 03 2001
a(34)-a(52) from Jon E. Schoenfield, Sep 02 2006
Definition corrected by Jon E. Schoenfield, Aug 27 2006
a(53)-a(55) added by Dmitry Kamenetsky, Jul 28 2008
a(55) corrected, a(56)-a(62) added by Dmitry Petukhov, Sep 20 2015
a(63)-a(67) added by Vladimir Chirkov and Natalia Makarova, Sep 25 2015, Sep 29 2015

A122412 Indices of primes occurring in A031133.

Original entry on oeis.org

1, 2, 3, 8, 15, 23, 29, 46, 188, 216, 326, 367, 738, 1183, 1662, 2224, 2225, 3384, 3385, 4058, 5948, 14356, 30802, 31544, 33608, 104070, 118504, 325851, 597310, 1319944, 2324139, 4140008, 4258994, 5911613, 8040877, 17567976, 23163297, 25203779
Offset: 1

Views

Author

Jon E. Schoenfield, Sep 02 2006

Keywords

Examples

			a(4)=8 because the 4th term of A031133 is the 8th prime number.
		

Crossrefs

Formula

a(n) = pi(A031133(n)).

A122413 Indices of primes occurring in A031134.

Original entry on oeis.org

3, 4, 5, 10, 17, 25, 31, 48, 190, 218, 328, 369, 740, 1185, 1664, 2226, 2227, 3386, 3387, 4060, 5950, 14358, 30804, 31546, 33610, 104072, 118506, 325853, 597312, 1319946, 2324141, 4140010, 4258996, 5911615, 8040879, 17567978, 23163299, 25203781
Offset: 1

Views

Author

Jon E. Schoenfield, Sep 02 2006

Keywords

Examples

			a(4)=10 because the 4th term of A031134 is the 10th prime number.
		

Crossrefs

Formula

a(n) = pi(A031134(n)).

A084105 Middle q of three consecutive primes p,q,r, such that one adjacent prime is near, the other is far and the ratio of the differences (whichever of (r-q)/(q-p) or (q-p)/(r-q) is greater than 1) sets a record.

Original entry on oeis.org

3, 29, 113, 139, 199, 523, 1151, 1669, 2971, 6947, 10007, 16141, 25471, 40639, 79699, 102761, 173359, 265621, 404851, 838249, 1349533, 1562051, 6371537, 7230479, 27980987, 42082303, 53231051, 70396589, 192983851, 253878617, 390932389, 465828731, 516540163, 1692327137
Offset: 1

Views

Author

Hugo Pfoertner, May 29 2003

Keywords

Comments

Are there entries other than a(3) for which the smaller difference exceeds 2?

Examples

			a(3) = 113 because the ratio (113-109)/(127-113) = 2/7 = 0.28571.. is smaller than the previous minimum produced by (31-29)/(29-23) = 1/3 = 0.33333...
		

Crossrefs

Programs

  • PARI
    a084105(limit)={my(p1=2,p2=3,r=0);forprime(p3=5,limit,my(q=max((p2-p1)/(p3-p2),(p3-p2)/(p2-p1)));if(q>r,r=q;print1(p2,", "));p1=p2;p2=p3)};
    a084105(600000000) \\ Hugo Pfoertner, Sep 04 2020

Extensions

More terms from Don Reble, May 29 2003
a(32)-a(34) from Hugo Pfoertner, Nov 06 2019

A096265 Aloof primes: Total distance between prime and neighboring primes sets record.

Original entry on oeis.org

2, 3, 5, 7, 23, 53, 89, 113, 211, 1129, 1327, 2179, 2503, 5623, 9587, 14107, 19609, 19661, 31397, 31469, 38501, 58831, 155921, 360749, 370261, 396833, 1357201, 1561919, 4652353, 8917523, 20831323, 38089277, 70396393, 72546283, 102765683
Offset: 1

Views

Author

Rick L. Shepherd, Jun 21 2004

Keywords

Examples

			a(1) = 2 as 2 has only one prime neighbor, 3 and 3-2 = 1, the first possible record. a(2) = 3 because the sum of the distances (gaps) from 3 to its two neighboring primes is 3-2 + 5-3 = 3 > 1, beating the previous record. a(5) = 23 because 23, with 29-19 = 10, is the smallest prime beating a(4) = 7's 11-5 = 6.
		

Crossrefs

Cf. A031132 (record distances corresponding to a(2) onward), A023186 (lonely primes), A087770 (lonely primes, another definition).

Programs

  • Mathematica
    PrimeNextDelta[n_]:=(Do[If[PrimeQ[n+k], a=n+k; d=a-n; Break[]], {k, 9!}]; d); PrimePrevDelta[n_]:=(Do[If[PrimeQ[n-k], a=n-k; d=n-a; Break[]], {k, n}]; d); q=0; lst={2}; Do[p=Prime[n]; d1=PrimeNextDelta[p]; d2=PrimePrevDelta[p]; d=d1+d2; If[d>q, AppendTo[lst, p]; q=d], {n, 2, 10^4}]; lst (* Vladimir Joseph Stephan Orlovsky, Aug 07 2008 *)
     Join[{2},DeleteDuplicates[{#[[2]],#[[3]]-#[[1]]}&/@Partition[Prime[Range[6 10^6]],3,1],GreaterEqual[#1[[2]],#2[[2]]]&][[All,1]]] (* Harvey P. Dale, Jul 05 2022 *)
  • PARI
    /* 436272953 is the next-to-the-largest precalculated prime */
    /* with which PARI/GP (Version 2.0.17 (beta) at least) can be started */
    /* A different program would be required to go beyond a(37)=325737821 */
    {r=0; print1("2,"); forprime(p=3,436272953,
    s=nextprime(p+1)-precprime(p-1); if(s>r, print1(p,","); r=s))}

A115401 Record differences between prime(n+3) and prime(n). Records in A031165.

Original entry on oeis.org

5, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 40, 42, 46, 50, 54, 58, 60, 62, 64, 68, 78, 84, 112, 116, 118, 120, 126, 128, 142, 152, 170, 178, 184, 192, 194, 198, 208, 210, 216, 220, 222, 252, 258, 270, 300, 318, 336, 348, 354, 370, 408
Offset: 1

Views

Author

Jonathan Vos Post, Jan 22 2006

Keywords

Comments

This is the k=3 case of the set of sequences "records in a(k,n) = prime(n+k) - prime(n)." The k=1 case is given by A005250 (ncreasing gaps between primes), A000101 [increasing gaps between primes (upper end)] and A002386, which gives lower ends of these gaps. The k=2 case is A031132. The merits of these records are (prime(n+3)-prime(n))/log (prime(n)). The first record merit is 5/log 2 = 16.6096405. The second record merit is 8/log 3 = 16.7672262.

Examples

			a(1) = A031165(1) = prime(4) - prime(1) = 7 - 2 = 5, which is the only odd element of this sequence.
a(2) = A031165(2) = prime(5) - prime(2) = 11 - 3 = 8.
a(3) = A031165(4) = prime(7) - prime(4) = 17 - 7 = 10.
a(4) = A031165(7) = prime(10) - prime(7) = 29 - 17 = 12.
a(5) = A031165(9) = prime(12) - prime(9) = 37 - 23 = 14.
		

Crossrefs

Programs

  • Mathematica
    NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ@k, k++ ]; k]; d = 0; p = 1; q = 2; r = 3; s = 5; lst = {}; Do[{p, q, r, s} = {q, r, s, NextPrim[s]}; If[s > d + p, d = s - p; AppendTo[lst, d]; Print[d]], {n, 10^8}] (* Robert G. Wilson v *)

Extensions

Corrected and extended by Robert G. Wilson v, Jan 23 2006
Showing 1-8 of 8 results.