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

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

A028334 Differences between consecutive odd primes, divided by 2.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

With an initial zero, gives the numbers of even numbers between two successive primes. - Giovanni Teofilatto, Nov 04 2005
Equal to difference between terms in A067076. - Eric Desbiaux, Aug 07 2010
The twin prime conjecture is that a(n) = 1 infinitely often. Yitang Zhang has proved that a(n) < 3.5 x 10^7 infinitely often. - Jonathan Sondow, May 17 2013
a(n) = 1 if, and only if, n + 1 is in A107770. - Jason Kimberley, Nov 13 2015

Examples

			23 - 19 = 4, so a(8) = 4/2 = 2.
29 - 23 = 6, so a(9) = 6/2 = 3.
31 - 29 = 2, so a(10) = 2/2 = 1.
		

References

  • Milton Abramowitz and Irene A. Stegun, eds., Handbook of Mathematical Functions, National Bureau of Standards Applied Math. Series 55, 1964 (and various reprintings), p. 870.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).

Crossrefs

Cf. A005521.
Cf. A000230 (least prime with a gap of 2n to the next prime).
Sequences related to the differences between successive primes: A001223 (Delta(p)), A028334, A080378, A104120, A330556 - A330561.

Programs

Formula

a(n) = A001223(n)/2 for n > 1.
a(n) = (prime(n+1) - prime(n)) / 2, where prime(n) is the n-th prime.
a(n) = A047160(A024675(n-1)). - Jason Kimberley, Nov 12 2015
G.f.: (b(x)/((x + 1)/((1 - x)) - 1) - 1 - x/2)/x, where b(x) is the g.f. of A000040. - Mario C. Enriquez, Dec 10 2016

Extensions

Replaced multiplication by division in the cross-reference R. J. Mathar, Jan 23 2010
Definition corrected by Jonathan Sondow, May 17 2013
Edited by Franklin T. Adams-Watters, Aug 07 2014

A080378 Residues mod 4 of the n-th difference between consecutive primes.

Original entry on oeis.org

1, 2, 2, 0, 2, 0, 2, 0, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 0, 2, 2, 0, 2, 0, 0, 2, 0, 2, 0, 2, 0, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 0, 2, 0, 2, 2, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2
Offset: 1

Views

Author

Labos Elemer, Mar 04 2003

Keywords

Crossrefs

Sequences related to the differences between successive primes: A001223 (Delta(p)), A028334, A080378, A104120, A330556-A330561.

Programs

  • Mathematica
    Table[Mod[Prime[w+1]-Prime[w], 4], {w, 1, 256}]
    Mod[Differences[Prime[Range[200]]], 4] (* Zak Seidov, Jun 26 2015 *)
  • Python
    from sympy import prime
    def A080378(n): return (prime(n+1)-prime(n))&3 # Chai Wah Wu, Jul 07 2022

Formula

a(n) = A001223(n) mod 4.

A330556 a(n) = (number of primes p <= 2*n+1 with Delta(p) == 2 mod 4) - (number of primes p <= 2*n+1 with Delta(p) == 0 mod 4), where Delta(p) = nextprime(p) - p.

Original entry on oeis.org

0, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 3, 4, 4, 4, 3, 3, 4, 3, 3, 4, 4, 4, 5, 5, 5, 6, 7, 7, 7, 6, 6, 7, 8, 8, 8, 7, 7, 8, 8, 8, 7, 7, 7, 7, 6, 6, 7, 6, 6, 7, 6, 6, 7, 7, 7, 7, 7, 7, 7, 6, 6, 7, 7, 7, 8, 9, 9, 9, 9, 9, 10, 11, 11, 11, 12, 12, 12, 11, 11, 12, 12, 12, 13, 13, 13
Offset: 0

Views

Author

N. J. A. Sloane, Dec 29 2019

Keywords

Comments

a(n) = A330557(n) - A330558(n).
Since Delta(prime(n)) grows roughly like log n, this probably changes sign infinitely often. When is the next time a(n) is zero, or the first time a(n) < 0 (if these values exist)?

Examples

			n=5, 2*n+1=11: there are three primes <= 11 with Delta(p) == 2 mod 4, namely 3,5,11; and one with Delta(p) == 0 mod 4, namely 7; so a(5) = 3-1 = 2.
		

Crossrefs

Sequences related to the differences between successive primes: A001223 (Delta(p)), A028334, A080378, A104120, A330556-A330561.

A330561 a(n) = number of primes p <= prime(n) with Delta(p) == 0 (mod 4), where Delta(p) = nextprime(p) - p.

Original entry on oeis.org

0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 15, 16, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 21, 21, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 25, 26, 27, 27, 27, 27, 27
Offset: 1

Views

Author

N. J. A. Sloane, Dec 30 2019

Keywords

Crossrefs

Cf. A098059.
Sequences related to the differences between successive primes: A001223 (Delta(p)), A028334, A080378, A104120, A330556, A330557, A330558, A330559, A330560.

Programs

  • Magma
    [#[p:p in PrimesInInterval(1,NthPrime(n))|IsIntegral((NextPrime(p)-p)/4)]:n in [1..80]]; // Marius A. Burtea, Dec 31 2019
  • Maple
    N:= 200: # for a(1)..a(N)
    P:= [seq(ithprime(i),i=1..N+1)]:
    Delta:= P[2..-1]-P[1..-2] mod 4:
    R:= map(charfcn[0],Delta):
    ListTools:-PartialSums(R); # Robert Israel, Dec 31 2019
  • Mathematica
    Accumulate[Map[Boole[Mod[#, 4] == 0]&, Differences[Prime[Range[100]]]]] (* Paolo Xausa, Feb 05 2024 *)

A330557 a(n) = number of primes p <= 2*n+1 with Delta(p) == 2 mod 4, where Delta(p) = nextprime(p) - p.

Original entry on oeis.org

0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 7, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 12, 12, 12, 12, 12, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 20, 21, 21
Offset: 0

Views

Author

N. J. A. Sloane, Dec 29 2019

Keywords

Crossrefs

Sequences related to the differences between successive primes: A001223 (Delta(p)), A028334, A080378, A104120, A330556-A330561.

Programs

  • Magma
    [#[p:p in PrimesInInterval(1,2*n+1)| (NextPrime(p)-p) mod 4 eq 2]:n in [0..80]]; // Marius A. Burtea, Dec 31 2019
  • Maple
    N:= 100: # for a(0)..a(N)
    P:= select(isprime, [seq(i,i=3..nextprime(2*N+1),2)]):
    Delta:= P[2..-1]-P[1..-2] mod 4:
    A:= Array(0..N): t:= 0: j:= 1:
    for n from 0 to N do
      m:= 2*n+1:
      if m = P[j] then t:= t + charfcn[2](Delta[j]); j:= j+1 fi;
      A[n]:= t
    od:
    convert(A,list); # Robert Israel, Dec 31 2019

A330558 a(n) = number of primes p <= 2*n+1 with Delta(p) == 0 mod 4, where Delta(p) = nextprime(p) - p.

Original entry on oeis.org

0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12
Offset: 0

Views

Author

N. J. A. Sloane, Dec 29 2019

Keywords

Crossrefs

Sequences related to the differences between successive primes: A001223 (Delta(p)), A028334, A080378, A104120, A330556-A330561.

Programs

  • Magma
    [#[p:p in PrimesInInterval(1,2*n+1)| (NextPrime(p)-p) mod 4 eq 0]:n in [0..80]]; // Marius A. Burtea, Dec 31 2019
  • Maple
    N:= 100: # for a(0)..a(N)
    P:= select(isprime, [seq(i,i=3..nextprime(2*N+1),2)]):
    Delta:= P[2..-1]-P[1..-2] mod 4:
    A:= Array(0..N): t:= 0: j:= 1:
    for n from 0 to N do
    m:= 2*n+1:
    if m = P[j] then t:= t + charfcn[0](Delta[j]); j:= j+1 fi;
    A[n]:= t
    od:
    convert(A,list); # Robert Israel, Dec 31 2019

A330559 a(n) = (number of primes p <= prime(n) with Delta(p) == 2 (mod 4)) - (number of primes p <= prime(n) with Delta(p) == 0 (mod 4)), where Delta(p) = nextprime(p) - p.

Original entry on oeis.org

0, 1, 2, 1, 2, 1, 2, 1, 2, 3, 4, 3, 4, 3, 4, 5, 6, 7, 6, 7, 8, 7, 8, 7, 6, 7, 6, 7, 6, 7, 6, 7, 8, 9, 10, 11, 12, 11, 12, 13, 14, 15, 16, 15, 16, 15, 14, 13, 14, 13, 14, 15, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 22, 23, 22, 23, 24, 25, 26, 25, 26, 25, 26, 27, 26, 27, 26, 25, 24, 25, 26, 27, 28, 29, 28
Offset: 1

Views

Author

N. J. A. Sloane, Dec 30 2019

Keywords

Comments

Equals A330560 - A330561.
Since Delta(prime(n)) grows roughly like log n, this probably changes sign infinitely often. When is the next time a(n) is zero, or the first time a(n) < 0 (if these values exist)?
Let s = A024675, the interprimes. For each n let E(n) = number of even terms of s that are <= n, and let O(n) = number of odd terms of s that are <= n. Then a(n+1) = E(n) - O(n). That is, as we progress through s, the number of evens stays greater than the number of odds. - Clark Kimberling, Feb 26 2024

Examples

			n=6: prime(6) = 13, primes p <= 13 with Delta(p) == 2 (mod 4) are 3,5,11; primes p <= 13 with Delta(p) == 0 (mod 4) are 7,13; so a(6) = 3-2 = 1.
		

Crossrefs

Sequences related to the differences between successive primes: A001223 (Delta(p)), A028334, A080378, A104120, A330556, A330557, A330558, A330560, A330561.

Programs

  • Mathematica
    Join[{0}, Accumulate[Mod[Differences[Prime[Range[2, 100]]], 4] - 1]] (* Paolo Xausa, Feb 05 2024 *)

A330560 a(n) = number of primes p <= prime(n) with Delta(p) == 2 (mod 4), where Delta(p) = nextprime(p) - p.

Original entry on oeis.org

0, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7, 7, 8, 8, 9, 10, 11, 12, 12, 13, 14, 14, 15, 15, 15, 16, 16, 17, 17, 18, 18, 19, 20, 21, 22, 23, 24, 24, 25, 26, 27, 28, 29, 29, 30, 30, 30, 30, 31, 31, 32, 33, 34, 35, 36, 37, 38, 39, 39, 40, 41, 42, 42, 43, 43, 44, 45, 46, 47, 47, 48, 48, 49, 50, 50, 51, 51, 51, 51, 52, 53, 54
Offset: 1

Views

Author

N. J. A. Sloane, Dec 30 2019

Keywords

Crossrefs

Sequences related to the differences between successive primes: A001223 (Delta(p)), A028334, A080378, A104120, A330556, A330557, A330558, A330559, A330561.

Programs

  • Magma
    [#[p:p in PrimesInInterval(1,NthPrime(n))| (NextPrime(p)-p) mod 4 eq 2]:n in [1..90]]; // Marius A. Burtea, Dec 31 2019
  • Maple
    N:= 200: # for a(1)..a(N)
    P:= [seq(ithprime(i), i=1..N+1)]:
    Delta:= P[2..-1]-P[1..-2] mod 4:
    R:= map(charfcn[2], Delta):
    ListTools:-PartialSums(R); # Robert Israel, Dec 31 2019
  • Mathematica
    Accumulate[Map[Boole[Mod[#, 4] == 2]&, Differences[Prime[Range[100]]]]] (* Paolo Xausa, Feb 05 2024 *)
Showing 1-9 of 9 results.