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-10 of 67 results. Next

A161795 The multiplicity of successive elements of sequence A005250 (increasing prime gaps) as they occur in A161794, the largest prime gap less than (n+1)^2.

Original entry on oeis.org

1, 1, 2, 4, 2, 12, 7, 3, 3, 61, 28, 15, 37, 217, 206, 8, 93, 460, 4, 253, 738
Offset: 1

Views

Author

Daniel Tisdale, Jun 19 2009

Keywords

Comments

Sequence A161794 suggests the size of prime gaps grows slower than the size of square intervals, lending credence to Legendre's conjecture.

Examples

			A161794 begins 1, 2, 4, 4, 6, 6, 6, 6, ... that is, 1 one, 1 two, 2 four, 4 six, ... so this sequence begins 1, 1, 2, 4, ...
		

Crossrefs

Programs

  • PARI
    f(n) = my(vp = primes(primepi((n+1)^2))); vecmax(vector(#vp-1, k, vp[k+1] - vp[k])); \\ A161794
    lista(nn) = my(v = vector(nn, k, f(k))); my(list = List(), last = v[1], nb=1); for (n=2, #v, if (v[n] == last, nb++, listput(list, nb); nb = 1; last = v[n];);); Vec(list); \\ Michel Marcus, Aug 15 2022

Extensions

a(15)-a(21) from Michel Marcus, Aug 15 2022

A001223 Prime gaps: differences between consecutive primes.

Original entry on oeis.org

1, 2, 2, 4, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, 2, 6, 4, 6, 8, 4, 2, 4, 2, 4, 14, 4, 6, 2, 10, 2, 6, 6, 4, 6, 6, 2, 10, 2, 4, 2, 12, 12, 4, 2, 4, 6, 2, 10, 6, 6, 6, 2, 6, 4, 2, 10, 14, 4, 2, 4, 14, 6, 10, 2, 4, 6, 8, 6, 6, 4, 6, 8, 4, 8, 10, 2, 10, 2, 6, 4, 6, 8, 4, 2, 4, 12, 8, 4, 8, 4, 6, 12
Offset: 1

Views

Author

Keywords

Comments

There is a unique decomposition of the primes: provided the weight A117078(n) is > 0, we have prime(n) = weight * level + gap, or A000040(n) = A117078(n) * A117563(n) + a(n). - Rémi Eismann, Feb 14 2008
Let rho(m) = A179196(m), for any n, let m be an integer such that p_(rho(m)) <= p_n and p_(n+1) <= p_(rho(m+1)), then rho(m) <= n < n + 1 <= rho(m + 1), therefore a(n) = p_(n+1) - p_n <= p_rho(m+1) - p_rho(m) = A182873(m). For all rho(m) = A179196(m), a(rho(m)) < A165959(m). - John W. Nicholson, Dec 14 2011
A solution (modular square root) of x^2 == A001248(n) (mod A000040(n+1)). - L. Edson Jeffery, Oct 01 2014
There exists a constant C such that for n -> infinity, Cramer conjecture a(n) < C log^2 prime(n) is equivalent to (log prime(n+1)/log prime(n))^n < e^C. - Thomas Ordowski, Oct 11 2014
a(n) = A008347(n+1) - A008347(n-1). - Reinhard Zumkeller, Feb 09 2015
Yitang Zhang proved lim inf_{n -> infinity} a(n) is finite. - Robert Israel, Feb 12 2015
lim sup_{n -> infinity} a(n)/log^2 prime(n) = C <==> lim sup_{n -> infinity}(log prime(n+1)/log prime(n))^n = e^C. - Thomas Ordowski, Mar 09 2015
a(A038664(n)) = 2*n and a(m) != 2*n for m < A038664(n). - Reinhard Zumkeller, Aug 23 2015
If j and k are positive integers then there are no two consecutive primes gaps of the form 2+6j and 2+6k (A016933) or 4+6j and 4+6k (A016957). - Andres Cicuttin, Jul 14 2016
Conjecture: For any positive numbers x and y, there is an index k such that x/y = a(k)/a(k+1). - Andres Cicuttin, Sep 23 2018
Conjecture: For any three positive numbers x, y and j, there is an index k such that x/y = a(k)/a(k+j). - Andres Cicuttin, Sep 29 2018
Conjecture: For any three positive numbers x, y and j, there are infinitely many indices k such that x/y = a(k)/a(k+j). - Andres Cicuttin, Sep 29 2018
Row m of A174349 lists all indices n for which a(n) = 2m. - M. F. Hasler, Oct 26 2018
Since (6a, 6b) is an admissible pattern of gaps for any integers a, b > 0 (and also if other multiples of 6 are inserted in between), the above conjecture follows from the prime k-tuple conjecture which states that any admissible pattern occurs infinitely often (see, e.g., the Caldwell link). This also means that any subsequence a(n .. n+m) with n > 2 (as to exclude the untypical primes 2 and 3) should occur infinitely many times at other starting points n'. - M. F. Hasler, Oct 26 2018
Conjecture: Defining b(n,j,k) as the number of pairs of prime gaps {a(i),a(i+j)} such that i < n, j > 0, and a(i)/a(i+j) = k with k > 0, then
lim_{n -> oo} b(n,j,k)/b(n,j,1/k) = 1, for any j > 0 and k > 0, and
lim_{n -> oo} b(n,j,k1)/b(n,j,k2) = C with C = C(j,k1,k2) > 0. - Andres Cicuttin, Sep 01 2019

References

  • M. Abramowitz and I. A. Stegun, eds., Handbook of Mathematical Functions, National Bureau of Standards Applied Math. Series 55, 1964 (and various reprintings), p. 870.
  • GCHQ, The GCHQ Puzzle Book, Penguin, 2016. See page 92.
  • Paulo Ribenboim, The Little Book of Bigger Primes, Springer-Verlag NY 2004. See pp. 186-192.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A000040 (primes), A001248 (primes squared), A000720, A037201, A007921, A030173, A036263-A036274, A167770, A008347.
Second difference is A036263, first occurrence is A000230.
For records see A005250, A005669.
Sequences related to the differences between successive primes: A001223 (Delta(p)), A028334, A080378, A104120, A330556-A330561.

Programs

  • Haskell
    a001223 n = a001223_list !! (n-1)
    a001223_list = zipWith (-) (tail a000040_list) a000040_list
    -- Reinhard Zumkeller, Oct 29 2011
    
  • Magma
    [(NthPrime(n+1) - NthPrime(n)): n in [1..100]]; // Vincenzo Librandi, Apr 02 2011
    
  • Maple
    with(numtheory): for n from 1 to 500 do printf(`%d,`,ithprime(n+1) - ithprime(n)) od:
  • Mathematica
    Differences[Prime[Range[100]]] (* Harvey P. Dale, May 15 2011 *)
  • PARI
    diff(v)=vector(#v-1,i,v[i+1]-v[i]);
    diff(primes(100)) \\ Charles R Greathouse IV, Feb 11 2011
    
  • PARI
    forprime(p=1, 1e3, print1(nextprime(p+1)-p, ", ")) \\ Felix Fröhlich, Sep 06 2014
    
  • Python
    from sympy import prime
    def A001223(n): return prime(n+1)-prime(n) # Chai Wah Wu, Jul 07 2022
  • Sage
    differences(prime_range(1000)) # Joerg Arndt, May 15 2011
    

Formula

G.f.: b(x)*(1-x), where b(x) is the g.f. for the primes. - Franklin T. Adams-Watters, Jun 15 2006
a(n) = prime(n+1) - prime(n). - Franklin T. Adams-Watters, Mar 31 2010
Conjectures: (i) a(n) = ceiling(prime(n)*log(prime(n+1)/prime(n))). (ii) a(n) = floor(prime(n+1)*log(prime(n+1)/prime(n))). (iii) a(n) = floor((prime(n)+prime(n+1))*log(prime(n+1)/prime(n))/2). - Thomas Ordowski, Mar 21 2013
A167770(n) == a(n)^2 (mod A000040(n+1)). - L. Edson Jeffery, Oct 01 2014
a(n) = Sum_{k=1..2^(n+1)-1} (floor(cos^2(Pi*(n+1)^(1/(n+1))/(1+primepi(k))^(1/(n+1))))). - Anthony Browne, May 11 2016
G.f.: (Sum_{k>=1} x^pi(k)) - 1, where pi(k) is the prime counting function. - Benedict W. J. Irwin, Jun 13 2016
Conjecture: Limit_{N->oo} (Sum_{n=2..N} log(a(n))) / (Sum_{n=2..N} log(log(prime(n)))) = 1. - Alain Rocchelli, Dec 16 2022
Conjecture: The asymptotic limit of the average of log(a(n)) ~ log(log(prime(n))) - gamma (where gamma is Euler's constant). Also, for n tending to infinity, the geometric mean of a(n) is equivalent to log(prime(n)) / e^gamma. - Alain Rocchelli, Jan 23 2023
It has been conjectured that primes are distributed around their average spacing in a Poisson distribution (cf. D. A. Goldston in above links). This is the basis of the last two conjectures above. - Alain Rocchelli, Feb 10 2023

Extensions

More terms from James Sellers, Feb 19 2001

A002386 Primes (lower end) with record gaps to the next consecutive prime: primes p(k) where p(k+1) - p(k) exceeds p(j+1) - p(j) for all j < k.

Original entry on oeis.org

2, 3, 7, 23, 89, 113, 523, 887, 1129, 1327, 9551, 15683, 19609, 31397, 155921, 360653, 370261, 492113, 1349533, 1357201, 2010733, 4652353, 17051707, 20831323, 47326693, 122164747, 189695659, 191912783, 387096133, 436273009, 1294268491
Offset: 1

Views

Author

Keywords

Comments

See the links by Jens Kruse Andersen et al. for very large gaps.

References

  • B. C. Berndt, Ramanujan's Notebooks Part IV, Springer-Verlag, see p. 133.
  • D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, Vol. 3, Sect 6.1, Table 1.
  • M. Kraitchik, Recherches sur la Théorie des Nombres. Gauthiers-Villars, Paris, Vol. 1, 1924, Vol. 2, 1929, see Vol. 1, p. 14.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A000040, A001223, A000101 (upper ends), A005250 (record gaps), A000230, A111870, A111943.
See also A205827(n) = A000040(A214935(n)), A182514(n) = A000040(A241540(n)).

Programs

  • Mathematica
    s = {2}; gm = 1; Do[p = Prime[n]; g = Prime[n + 1] - p; If[g > gm, Print[p]; AppendTo[s, p]; gm = g], {n, 2, 1000000}]; s   (* Jean-François Alcover, Mar 31 2011 *)
    Module[{nn=10^7,pr,df},pr=Prime[Range[nn]];df=Differences[pr];DeleteDuplicates[ Thread[ {Most[ pr],df}],GreaterEqual[#1[[2]],#2[[2]]]&]][[All,1]] (* The program generates the first 26 terms of the sequence. *) (* Harvey P. Dale, Sep 24 2022 *)
  • PARI
    a(n)=local(p,g);if(n<2,2*(n>0),p=a(n-1);g=nextprime(p+1)-p;while(p=nextprime(p+1),if(nextprime(p+1)-p>g,break));p) /* Michael Somos, Feb 07 2004 */
    
  • PARI
    p=q=2;g=0;until( g<(q=nextprime(1+p=q))-p && print1(q-g=q-p,","),) \\ M. F. Hasler, Dec 13 2007

Formula

a(n) = A000101(n) - A005250(n) = A008950(n-1) - 1. - M. F. Hasler, Dec 13 2007
A000720(a(n)) = A005669(n).
a(n) = A000040(A005669(n)). - M. F. Hasler, Apr 26 2014

Extensions

Definition clarified by Harvey P. Dale, Sep 24 2022

A000230 a(0)=2; for n>=1, a(n) = smallest prime p such that there is a gap of exactly 2n between p and next prime, or -1 if no such prime exists.

Original entry on oeis.org

2, 3, 7, 23, 89, 139, 199, 113, 1831, 523, 887, 1129, 1669, 2477, 2971, 4297, 5591, 1327, 9551, 30593, 19333, 16141, 15683, 81463, 28229, 31907, 19609, 35617, 82073, 44293, 43331, 34061, 89689, 162143, 134513, 173359, 31397, 404597, 212701, 188029, 542603, 265621, 461717, 155921, 544279, 404851, 927869, 1100977, 360653, 604073
Offset: 0

Views

Author

Keywords

Comments

p + 1 = A045881(n) starts the smallest run of exactly 2n-1 successive composite numbers. - Lekraj Beedassy, Apr 23 2010
Weintraub gives upper bounds on a(252), a(255), a(264), a(273), and a(327) based on a search from 1.1 * 10^16 to 1.1 * 10^16 + 1.5 * 10^9, probably performed on a 1970s microcomputer. - Charles R Greathouse IV, Aug 26 2022

Examples

			The following table, based on a very much larger table in the web page of Tomás Oliveira e Silva (see link) shows, for each gap g, P(g) = the smallest prime such that P(g)+g is the smallest prime number larger than P(g);
* marks a record-holder: g is a record-holder if P(g') > P(g) for all (even) g' > g, i.e., if all prime gaps are smaller than g for all primes smaller than P(g); P(g) is a record-holder if P(g') < P(g) for all (even) g' < g.
This table gives rise to many sequences: P(g) is A000230, the present sequence; P(g)* is A133430; the positions of the *'s in the P(g) column give A100180, A133430; g* is A005250; P(g*) is A002386; etc.
   -----
   g P(g)
   -----
   1* 2*
   2* 3*
   4* 7*
   6* 23*
   8* 89*
   10 139*
   12 199*
   14* 113
   16 1831*
   18* 523
   20* 887
   22* 1129
   24 1669
   26 2477*
   28 2971*
   30 4297*
   32 5591*
   34* 1327
   36* 9551*
   ........
The first time a gap of 4 occurs between primes is between 7 and 11, so a(2)=7 and A001632(2)=11.
		

References

  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

A001632(n) = 2n + a(n) = nextprime(a(n)).
Cf. A100964 (least prime number that begins a prime gap of at least 2n).

Programs

Formula

a(n) = A000040(A038664(n)). - Lekraj Beedassy, Sep 09 2006

Extensions

a(29)-a(37) from Jud McCranie, Dec 11 1999
a(38)-a(49) from Robert A. Stump (bee_ess107(AT)yahoo.com), Jan 11 2002
"or -1 if ..." added to definition at the suggestion of Alexander Wajnberg by N. J. A. Sloane, Feb 02 2020

A000101 Record gaps between primes (upper end) (compare A002386, which gives lower ends of these gaps).

Original entry on oeis.org

3, 5, 11, 29, 97, 127, 541, 907, 1151, 1361, 9587, 15727, 19661, 31469, 156007, 360749, 370373, 492227, 1349651, 1357333, 2010881, 4652507, 17051887, 20831533, 47326913, 122164969, 189695893, 191913031, 387096383, 436273291, 1294268779
Offset: 1

Views

Author

Keywords

Comments

See A002386 for complete list of known terms and further references.
Except for a(1)=3 and a(2)=5, a(n) = A168421(k). Primes 3 and 5 are special in that they are the only primes which do not have a Ramanujan prime between them and their double, <= 6 and 10 respectively. Because of the large size of a gap, there are many repeats of the prime number in A168421. - John W. Nicholson, Dec 10 2013

References

  • B. C. Berndt, Ramanujan's Notebooks Part IV, Springer-Verlag, see p. 133.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A000040, A001223 (differences between primes), A002386 (lower ends), A005250 (record gaps), A107578.
Cf. also A005669, A111943.

Programs

  • Mathematica
    s = {3}; gm = 1; Do[p = Prime[n + 1]; g = p - Prime[n]; If[g > gm, Print[p]; AppendTo[s, p]; gm = g], {n, 2, 1000000}]; s  (* Jean-François Alcover, Mar 31 2011 *)
  • PARI
    p=q=2;g=0;until( g<(q=nextprime(1+p=q))-p & print1(p+g=q-p,","),) \\ M. F. Hasler, Dec 13 2007

Formula

a(n) = A002386(n) + A005250(n) = A008995(n-1) + 1. - M. F. Hasler, Dec 13 2007

A049711 a(n) = n - prevprime(n).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

All runs end in even numbers at a(p), new highs are found at A000101 and the increasing gap size is A005250. - Robert G. Wilson v, Dec 07 2001
All terms are positive since here the variant 2 (A151799(n) < n) of the prevprime function is used, rather than the variant 1 (A007917(n) <= n). - M. F. Hasler, Sep 09 2015

Crossrefs

Programs

  • Maple
    A049711 := n-> n-prevprime(n);
  • Mathematica
    PrevPrim[n_] := Block[ {k = n - 1}, While[ !PrimeQ[k], k-- ]; Return[k]]; Table[ n - PrevPrim[n], {n, 3, 100} ]
    Array[#-NextPrime[#,-1]&,100,3] (* Harvey P. Dale, Dec 07 2011 *)
  • PARI
    A049711(n)=n-precprime(n-1) \\ M. F. Hasler, Sep 09 2015

Formula

a(n) = A064722(n-1) + 1. - Pontus von Brömssen, Jul 31 2022

A005669 Indices of primes where largest gap occurs.

Original entry on oeis.org

1, 2, 4, 9, 24, 30, 99, 154, 189, 217, 1183, 1831, 2225, 3385, 14357, 30802, 31545, 40933, 103520, 104071, 149689, 325852, 1094421, 1319945, 2850174, 6957876, 10539432, 10655462, 20684332, 23163298, 64955634, 72507380, 112228683, 182837804, 203615628, 486570087
Offset: 1

Views

Author

Keywords

Comments

Conjecture: log a(n) ~ n/2. That is, record prime gaps occur about twice as often as records in an i.i.d. random sequence of comparable length (see arXiv:1709.05508 for a heuristic explanation). - Alexei Kourbatov, Mar 28 2018

References

  • H. Riesel, Prime numbers and computer methods for factorization, Progress in Mathematics, Vol. 57, Birkhäuser, Boston, 1985, Chap. 4, see pp. 381-384.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{d, i, m = 0}, Reap@ For[i = 1, i <= n, i++, d = Prime[i + 1] - Prime@ i; If[d > m, m = d; Sow@ i, False]] // Flatten // Rest]; f@ 1000000 (* Michael De Vlieger, Mar 24 2015 *)

Formula

a(n) = A000720(A002386(n)).
a(n) = A107578(n) - 1. - Jens Kruse Andersen, Oct 19 2010

A113274 Record gaps between twin primes.

Original entry on oeis.org

2, 6, 12, 18, 30, 36, 72, 150, 168, 210, 282, 372, 498, 630, 924, 930, 1008, 1452, 1512, 1530, 1722, 1902, 2190, 2256, 2832, 2868, 3012, 3102, 3180, 3480, 3804, 4770, 5292, 6030, 6282, 6474, 6552, 6648, 7050, 7980, 8040, 8994, 9312, 9318, 10200, 10338, 10668
Offset: 1

Views

Author

Bernardo Boncompagni, Oct 21 2005

Keywords

Comments

a(n) mod 6 = 0 for each n>1.

Examples

			The first twin primes are 3,5 and 5,7 so a(0)=5-3=2. The following pair is 11,13 so a(1)=11-5=6. The following pair is 17,19 so 6 remains the record and no terms are added.
		

Crossrefs

The smallest primes originating the sequence are given in A113275. Cf. A008407, A005250, A002386.

Programs

  • Mathematica
    NextLowerTwinPrim[n_] := Block[{k = n + 6}, While[ !PrimeQ[k] || !PrimeQ[k + 2], k+=6]; k]; p = 5; r = 2; t = {2}; Do[ q = NextLowerTwinPrim[p]; If[q > r + p, AppendTo[t, q - p]; Print[{p, q - p}]; r = q - p]; p = q, {n, 10^9}]; t (* Robert G. Wilson v, Oct 22 2005 *)
    DeleteDuplicates[Differences[Select[Partition[Prime[Range[10^7]],2,1],#[[2]]-#[[1]] == 2&][[All,2]]],GreaterEqual] (* The program generates the first 27 terms of the sequence. *) (* Harvey P. Dale, Dec 31 2022 *)

Formula

a(n) = A036063(n) + 2.
a(n) = A036062(n) - A113275(n).
From Alexei Kourbatov, Dec 29 2011: (Start)
(1) Upper bound: gaps between twin primes are smaller than 0.76*(log p)^3, where p is the prime at the end of the gap.
(2) Estimate for the actual size of the maximal gap that ends at p: maximal gap = a(log(p/a)-1.2), where a = 0.76*(log p)^2 is the average gap between twin primes near p, as predicted by the Hardy-Littlewood k-tuple conjecture.
Formulas (1) and (2) are asymptotically equal as p tends to infinity. However, (1) yields values greater than all known gaps, while (2) yields "good guesses" that may be either above or below the actual size of known maximal gaps.
Both formulas (1) and (2) are derived from the Hardy-Littlewood k-tuple conjecture via probability-based heuristics relating the expected maximal gap size to the average gap. Neither of the formulas has a rigorous proof (the k-tuple conjecture itself has no formal proof either). In both formulas, the constant ~0.76 is reciprocal to the twin prime constant 1.32032...
(End)

Extensions

More terms from Robert G. Wilson v, Oct 22 2005
Corrected terms based on A036063, cross-checked with independent computations by Carlos Rivera and Richard Fischer (linked).
Terms up to a(72) are given in Kourbatov (2013), terms up to a(75) in Oliveira e Silva website.

A014320 The next new gap between successive primes.

Original entry on oeis.org

1, 2, 4, 6, 8, 14, 10, 12, 18, 20, 22, 34, 24, 16, 26, 28, 30, 32, 36, 44, 42, 40, 52, 48, 38, 72, 50, 62, 54, 60, 58, 46, 56, 64, 68, 86, 66, 70, 78, 76, 82, 96, 112, 100, 74, 90, 84, 114, 80, 88, 98, 92, 106, 94, 118, 132, 104, 102, 110, 126, 120, 148, 108, 122, 138
Offset: 1

Views

Author

Hynek Mlcousek (hynek(AT)dior.ics.muni.cz)

Keywords

Comments

Prime differences A001223 in natural order with duplicates removed. - Reinhard Zumkeller, Apr 03 2015
Conjecture: a(n) = O(n). See arXiv:2002.02115 for discussion. - Alexei Kourbatov, Jun 04 2020

Examples

			The first two primes are 2 and 3, and the first prime gap is 3 - 2 = 1; so a(1) = 1. The next prime is 5, and the next gap is 5 - 3 = 2; this gap size has not occurred before, so a(2) = 2. The next prime is 7, and the next gap is 7 - 5 = 2; the gap size 2 has already occurred before, so nothing is added to the sequence.
		

Crossrefs

Programs

  • Haskell
    import Data.List (nub)
    a014320 n = a014320_list !! (n-1)
    a014320_list = nub $ a001223_list
    -- Reinhard Zumkeller, Apr 03 2015
    
  • Mathematica
    max = 300000; allGaps = Transpose[ {gaps = Differences[ Prime[ Range[max]]], Range[ Length[gaps]]}]; equalGaps = Split[ Sort[ allGaps, #1[[1]] < #2[[1]] & ], #1[[1]] == #2[[1]] & ]; firstGaps = ((Sort[#1, #1[[1]] < #2[[1]] & ] & ) /@ equalGaps)[[All, 1]]; Sort[ firstGaps, #1[[2]] < #2[[2]] & ][[All, 1]] (* Jean-François Alcover, Oct 21 2011 *)
    DeleteDuplicates[Differences[Prime[Range[10000]]]] (* Alonso del Arte, Jun 05 2020 *)
  • PARI
    my(isFirstOcc=vector(9999, j, 1), s=2); forprime(p=3, 1e8, my(g=p-s); if(isFirstOcc[g], print1(g, ", "); isFirstOcc[g]=0); s=p) \\ Alexei Kourbatov, Jun 03 2020
    
  • Scala
    val prime: LazyList[Int] = 2 #:: LazyList.from(3).filter(i => prime.takeWhile {
       j => j * j <= i
    }.forall {
       k => i % k != 0
    })
    val primes = prime.take(1000).toList
    primes.zip(primes.tail).map(p => p.2 - p._1).distinct // _Alonso del Arte, Jun 04 2020

Formula

a(n) = A335367(n) - A335366(n). - Alexei Kourbatov, Jun 04 2020
a(n) = 2*A014321(n-1) for n >= 2. - Robert Israel, May 27 2024

Extensions

More terms from Sascha Kurz, Mar 24 2002

A008996 Increasing length runs of consecutive composite numbers (records).

Original entry on oeis.org

1, 3, 5, 7, 13, 17, 19, 21, 33, 35, 43, 51, 71, 85, 95, 111, 113, 117, 131, 147, 153, 179, 209, 219, 221, 233, 247, 249, 281, 287, 291, 319, 335, 353, 381, 383, 393, 455, 463, 467, 473, 485, 489, 499, 513, 515, 531, 533, 539, 581, 587, 601, 651, 673, 715, 765
Offset: 1

Views

Author

Mark Cramer (m.cramer(AT)qut.edu.au), Mar 15 1996

Keywords

Comments

Conjecture: a(n) = O(n^2); specifically, a(n) <= n^2. - Alexei Kourbatov, Jan 23 2019

Crossrefs

Programs

  • Haskell
    a008996 n = a008996_list !! (n-1)
    a008996_list = 1 : f 0 (filter (> 1) $
                            map length $ group $ drop 3 a010051_list)
       where f m (u : us) = if u <= m then f m us else u : f u us
    -- Reinhard Zumkeller, Nov 27 2012
  • Mathematica
    maxGap = 1; Reap[ Do[ gap = Prime[n+1] - Prime[n]; If[gap > maxGap, Print[gap-1]; Sow[gap-1]; maxGap = gap], {n, 2, 10^8}]][[2, 1]] (* Jean-François Alcover, Jun 12 2013 *)
    Module[{nn=10^8,cmps},cmps=Table[If[CompositeQ[n],1,{}],{n,nn}];DeleteDuplicates[ Rest[ Length/@ Split[cmps]],GreaterEqual]] (* The program generates the first 24 terms of the sequnece. To generate more, increase the nn constant. *) (* Harvey P. Dale, Sep 04 2022 *)

Formula

a(n) = A005250(n+1) - 1.

Extensions

More terms from Warren D. Smith, Dec 11 2000
a(40) corrected by Bert Sierra, Jul 12 2025
Showing 1-10 of 67 results. Next