login
Smallest prime p such that there is a gap of exactly n! between p and the next prime.
0

%I #23 Oct 28 2021 12:37:08

%S 2,2,3,23,1669,1895359,111113196467011

%N Smallest prime p such that there is a gap of exactly n! between p and the next prime.

%C a(7) > 1.5 * 10^18. - _Charles R Greathouse IV_, Jun 30 2011

%C a(7) <=

%C 5321252506668526413269161812412779312234715413010708809313699883082142158368298199 (see the Nicely page). - _Abhiram R Devesh_, Aug 09 2014

%H Thomas R. Nicely, <a href="https://faculty.lynchburg.edu/~nicely/gaps/gaplist.html">First occurrence prime gaps</a> [For local copy see A000101]

%F a(n) = A000230(n!/2) for n > 1. - _Charles R Greathouse IV_, Jun 30 2011

%e a(4) = 1669 because the next prime after 1669 is 1693 and 1693 - 1669 = 24 = 4!

%p with(numtheory):for n from 0 to 10 do:id:=0:for k from 1 to 2000000 while(id=0) do:p1:=ithprime(k):p2:=ithprime(k+1):if p2-p1 = n! then id:=1: printf(`%d, `,p1): else fi:od:od:

%t f[n_] := Block[{k = 1}, While[Prime[k + 1] != n + Prime[k], k++ ]; Prime[k]]; Do[ Print[ f[n!]], {n, 0, 10}]

%o (PARI) a(n)=my(p=2);n=n!;forprime(q=3,default(primelimit),if(q-p==n,return(p));p=q) \\ _Charles R Greathouse IV_, Jun 30 2011

%o (Python)

%o import sympy

%o n=0

%o while n>=0:

%o ....p=2

%o ....while sympy.nextprime(p)-p!=(sympy.factorial(n)):

%o ........p=sympy.nextprime(p)

%o ....print(p)

%o ....n=n+1

%o ....p=sympy.nextprime(p)

%o ## _Abhiram R Devesh_, Aug 09 2014

%K nonn,hard

%O 0,1

%A _Michel Lagneau_, Jun 30 2011

%E a(6) from _Charles R Greathouse IV_, Jun 30 2011