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.

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

This page as a plain text file.
%I A031131 #75 Apr 16 2025 07:27:33
%S A031131 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,
%T A031131 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,
%U A031131 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
%N A031131 Difference between n-th prime and (n+2)-nd prime.
%C A031131 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]
%C A031131 A031131(A261525(n)) = 2*n and A031131(m) != 2*n for m < A261525(n). - _Reinhard Zumkeller_, Aug 23 2015
%C A031131 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
%H A031131 T. D. Noe, <a href="/A031131/b031131.txt">Table of n, a(n) for n = 1..10000</a>
%H A031131 D. H. J. Polymath, <a href="https://doi.org/10.1186/s40687-014-0012-7">Variants of the Selberg sieve, and bounded intervals containing many primes</a>, Research in the Mathematical Sciences 1:12 (2014).
%H A031131 Polymath project, <a href="http://michaelnielsen.org/polymath1/index.php?title=Bounded_gaps_between_primes">Bounded gaps between primes</a>
%F A031131 a(n) = A001223(n) + A001223(n-1). - _Lior Manor_, Jan 19 2005
%F A031131 a(n) = A000040(n+2) - A000040(n).
%F A031131 a(n) = 2*A052288(n-1) for n>1. - _Hugo Pfoertner_, Apr 16 2025
%e A031131 a(10)=8 because the 10th prime=29 is followed by primes 31 and 37, and 37 - 29 = 8.
%p A031131 P:= select(isprime, [2,seq(2*i+1,i=1..1000)]):
%p A031131 P[3..-1] - P[1..-3]; # _Robert Israel_, Jan 25 2015
%t A031131 Differences[lst_]:=Drop[lst,2]-Drop[lst,-2]; Differences[Prime[Range[123]]] (* _Vladimir Joseph Stephan Orlovsky_, Aug 13 2009 *)
%t A031131 Map[#3 - #1 & @@ # &, Partition[Prime@ Range[84], 3, 1]] (* _Michael De Vlieger_, Dec 17 2017 *)
%o A031131 (MuPAD) ithprime(i+2)-ithprime(i) $ i = 1..65 // _Zerinvary Lajos_, Feb 26 2007
%o A031131 (Sage)
%o A031131 BB = primes_first_n(67)
%o A031131 L = []
%o A031131 for i in range(65):
%o A031131     L.append(BB[2+i]-BB[i])
%o A031131 L
%o A031131 # _Zerinvary Lajos_, May 14 2007
%o A031131 (Magma) [NthPrime(n+2)-NthPrime(n): n in [1..100] ]; // _Vincenzo Librandi_, Apr 11 2011
%o A031131 (PARI) a(n)=my(p=prime(n));nextprime(nextprime(p+1)+1)-p \\ _Charles R Greathouse IV_, Jul 01 2013
%o A031131 (Haskell)
%o A031131 a031131 n = a031131_list !! (n-1)
%o A031131 a031131_list = zipWith (-) (drop 2 a000040_list) a000040_list
%o A031131 -- _Reinhard Zumkeller_, Dec 19 2013
%Y A031131 Sum of consecutive terms of A001223.
%Y A031131 Cf. A031132, A031133, A031134, A122412, A122413,A046931, A000040, A031165, A031166, A031167, A031168, A031169, A031170, A031171, A031172, A261525, A052288.
%Y A031131 Cf. A075527 (allowing 1 to be prime).
%Y A031131 First differences of A001043.
%K A031131 nonn
%O A031131 1,1
%A A031131 _Jeff Burch_
%E A031131 Corrected by _T. D. Noe_, Sep 11 2008
%E A031131 Edited by _N. J. A. Sloane_, Sep 18 2008, at the suggestion of _T. D. Noe_