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.

A014320 The next new gap between successive primes.

This page as a plain text file.
%I A014320 #59 Feb 03 2025 14:43:35
%S A014320 1,2,4,6,8,14,10,12,18,20,22,34,24,16,26,28,30,32,36,44,42,40,52,48,
%T A014320 38,72,50,62,54,60,58,46,56,64,68,86,66,70,78,76,82,96,112,100,74,90,
%U A014320 84,114,80,88,98,92,106,94,118,132,104,102,110,126,120,148,108,122,138
%N A014320 The next new gap between successive primes.
%C A014320 Prime differences A001223 in natural order with duplicates removed. - _Reinhard Zumkeller_, Apr 03 2015
%C A014320 Conjecture: a(n) = O(n). See arXiv:2002.02115 for discussion. - _Alexei Kourbatov_, Jun 04 2020
%H A014320 Brian Kehrig, <a href="/A014320/b014320.txt">Table of n, a(n) for n = 1..754</a> (terms 1..120 from Reinhard Zumkeller, 121..745 from Alexei Kourbatov).
%H A014320 Alexei Kourbatov and Marek Wolf, <a href="https://arxiv.org/abs/2002.02115">On the first occurrences of gaps between primes in a residue class</a>, arXiv preprint arXiv:2002.02115 [math.NT], 2020.
%F A014320 a(n) = A335367(n) - A335366(n). - _Alexei Kourbatov_, Jun 04 2020
%F A014320 a(n) = 2*A014321(n-1) for n >= 2. - _Robert Israel_, May 27 2024
%e A014320 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.
%t A014320 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 *)
%t A014320 DeleteDuplicates[Differences[Prime[Range[10000]]]] (* _Alonso del Arte_, Jun 05 2020 *)
%o A014320 (Haskell)
%o A014320 import Data.List (nub)
%o A014320 a014320 n = a014320_list !! (n-1)
%o A014320 a014320_list = nub $ a001223_list
%o A014320 -- _Reinhard Zumkeller_, Apr 03 2015
%o A014320 (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
%o A014320 (Scala) val prime: LazyList[Int] = 2 #:: LazyList.from(3).filter(i => prime.takeWhile {
%o A014320    j => j * j <= i
%o A014320 }.forall {
%o A014320    k => i % k != 0
%o A014320 })
%o A014320 val primes = prime.take(1000).toList
%o A014320 primes.zip(primes.tail).map(p => p._2 - p._1).distinct // _Alonso del Arte_, Jun 04 2020
%Y A014320 Cf. A000101, A001223, A002386, A005250, A330853, A334543, A335366, A335367.
%K A014320 nonn
%O A014320 1,2
%A A014320 Hynek Mlcousek (hynek(AT)dior.ics.muni.cz)
%E A014320 More terms from _Sascha Kurz_, Mar 24 2002