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.

A309877 a(n) is the smallest number k such that the difference between the next prime greater than k and k equals n.

This page as a plain text file.
%I A309877 #14 Mar 23 2025 15:09:41
%S A309877 1,0,8,7,24,23,90,89,118,117,116,115,114,113,526,525,524,523,888,887,
%T A309877 1130,1129,1338,1337,1336,1335,1334,1333,1332,1331,1330,1329,1328,
%U A309877 1327,9552,9551,15690,15689,15688,15687,15686,15685,15684,15683,19616,19615,19614,19613,19612,19611
%N A309877 a(n) is the smallest number k such that the difference between the next prime greater than k and k equals n.
%H A309877 Robert Israel, <a href="/A309877/b309877.txt">Table of n, a(n) for n = 1..282</a>
%F A309877 a(n) = min {k : A013632(k) = n}.
%e A309877 +------+------+-----+
%e A309877 | a(n) | next | gap |
%e A309877 |      | prime|     |
%e A309877 +------+------+-----+
%e A309877 |   1  |   2  |  1  |
%e A309877 |   0  |   2  |  2  |
%e A309877 |   8  |  11  |  3  |
%e A309877 |   7  |  11  |  4  |
%e A309877 |  24  |  29  |  5  |
%e A309877 |  23  |  29  |  6  |
%e A309877 |  90  |  97  |  7  |
%e A309877 |  89  |  97  |  8  |
%e A309877 +------+------+-----+
%p A309877 N:= 100:
%p A309877 A:= Vector(N,-1):
%p A309877 count:= 0: lastp:= 0:
%p A309877 while count < N do
%p A309877   p:= nextprime(lastp);
%p A309877   newvals:= select(t -> A[t]=-1, [$1..min(p-lastp,N)]);
%p A309877   count:= count+nops(newvals);
%p A309877   for k in newvals do A[k]:= p-k od;
%p A309877   lastp:= p;
%p A309877 od:
%p A309877 convert(A,list); # _Robert Israel_, Aug 23 2019
%t A309877 Table[SelectFirst[Range[0, 20000], NextPrime[#] - # == n &], {n, 1, 50}]
%t A309877 Module[{nn=20000,d},d=Table[{n,NextPrime[n]-n},{n,0,nn}];Table[SelectFirst[d,#[[2]]==k&],{k,50}]][[;;,1]] (* _Harvey P. Dale_, Mar 23 2025 *)
%o A309877 (PARI) a(n) = my(k=0); while(nextprime(k+1) - k != n, k++); k; \\ _Michel Marcus_, Aug 21 2019
%Y A309877 Cf. A000101, A000230, A007918, A007920, A013632, A051652, A075403, A077019, A151800.
%K A309877 nonn
%O A309877 1,3
%A A309877 _Ilya Gutkovskiy_, Aug 21 2019