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.

A166597 Let p = largest prime <= n, with p(0)=p(1)=0, and let q = smallest prime > n; then a(n) = q-p.

This page as a plain text file.
%I A166597 #24 Feb 16 2025 08:33:11
%S A166597 2,2,1,2,2,2,2,4,4,4,4,2,2,4,4,4,4,2,2,4,4,4,4,6,6,6,6,6,6,2,2,6,6,6,
%T A166597 6,6,6,4,4,4,4,2,2,4,4,4,4,6,6,6,6,6,6,6,6,6,6,6,6,2,2,6,6,6,6,6,6,4,
%U A166597 4,4,4,2,2,6,6,6,6,6,6,4,4,4,4,6,6,6,6,6,6,8,8,8,8,8,8,8,8,4,4,4,4,2,2,4,4
%N A166597 Let p = largest prime <= n, with p(0)=p(1)=0, and let q = smallest prime > n; then a(n) = q-p.
%C A166597 Note the large prime gap of 72 between 31397 and 31469. This is the prime gap with the largest merit (cf. A111870), 72/log(31397)=6.95352 for primes less than 100000. Also 72/(log(31397))^2=0.67154 (cf. conjectures of Cramer-Granville, Shanks and Wolf) is largest for primes less than 100000. - _Daniel Forgues_, Oct 23 2009
%H A166597 Daniel Forgues, <a href="/A166597/b166597.txt">Table of n, a(n) for n = 0..100000</a>
%H A166597 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PrimeGaps.html">Prime Gaps</a>.
%H A166597 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/Cramer-GranvilleConjecture.html">Cramer-Granville Conjecture</a>.
%H A166597 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/ShanksConjecture.html">Shanks Conjecture</a>.
%F A166597 From _Ridouane Oudra_, Dec 28 2024: (Start)
%F A166597 a(n) = A001223(A000720(n)), for n>1.
%F A166597 a(n) = A151800(n) - A007917(n), for n>1.
%F A166597 a(n) = A007918(n+1) - A151799(n+1), for n>1. (End)
%e A166597 a(0) = 2 since the least prime greater than 0 is 2 (gap of 2 from 0 to 2).
%e A166597 a(9) = 4 since the least prime greater than 9 is 11 (gap of 4 from 7 to 11).
%e A166597 a(11) = 2 since the least prime greater than 11 is 13 (gap of 2 from 11 to 13).
%p A166597 2,2,seq(nextprime(n)-prevprime(n+1), n=2..100); # _Ridouane Oudra_, Dec 28 2024
%t A166597 f[n_]:=Module[{a=If[PrimeQ[n],n,NextPrime[n,-1]]}, NextPrime[n]-a]; Join[{2,2},Array[f,120,2]] (* _Harvey P. Dale_, May 17 2011 *)
%o A166597 (PARI) a(n) = nextprime(n+1) - precprime(n); \\ _Michel Marcus_, Mar 02 2023
%Y A166597 Cf. A151800, A166594.
%Y A166597 Cf. A111870. - _Daniel Forgues_, Oct 23 2009
%Y A166597 See A327441 for the classic G(n) version. - _N. J. A. Sloane_, Sep 11 2019
%Y A166597 Cf. A001223, A000720, A007917, A007918, A151799.
%K A166597 nonn
%O A166597 0,1
%A A166597 _Daniel Forgues_, Oct 17 2009
%E A166597 Definition rephrased by _N. J. A. Sloane_, Oct 25 2009