login
The prime gap, divided by two, which surrounds n!.
3

%I #37 Jan 23 2021 23:25:48

%S 1,3,7,4,6,27,15,11,7,15,45,10,45,38,45,39,95,30,31,52,93,102,95,48,

%T 22,84,127,54,94,40,19,145,87,129,49,22,85,68,66,88,90,78,146,95,156,

%U 78,71,79,225,60,65,175,66,305,192,196,215,205,420,101,186,213,160

%N The prime gap, divided by two, which surrounds n!.

%C A theorem states that between (n+1)! + 2 and (n+1)! + (n+1) inclusive, there are n consecutive composite integers, namely 2, 3, 4, ..., n, n+1.

%C Records: 1, 3, 7, 27, 45, 95, 102, 127, 145, 146, 156, 225, 305, 420, 804, 844, 1173, 1671, 1725, 1827, 2570, 2930, 3318, 5142, 5946, 6837, 7007, 8208, 10221, ..., .

%H Robert Israel, <a href="/A340013/b340013.txt">Table of n, a(n) for n = 3..607</a>

%F a(n) = (A037151(n) - A006990(n))/2 = (A033932(n) + A033933(n))/2.

%F a(n) = A054588(n)/2 = A058054(n)/2. - _Alois P. Heinz_, Jan 09 2021

%e For a(1), there are no positive primes which surround 1!. Therefore a(1) is undefined.

%e For a(2), there are two contiguous primes {2, 3} with 2 being 2!. The prime gap is 1. However, the two primes do not surround 2!, so a(2) is undefined.

%e For a(3), the following set of numbers, {5, 6, 7}, with 3! being in the middle. The prime gap is 2; therefore, a(3) = 1.

%e For a(4), the following set of numbers, {23, 24, 25, 26, 27, 28, 29} with 4! in between the two primes 23 & 29. The prime gap is 6, so a(4) = 3.

%p a:= n-> (f-> (nextprime(f-1)-prevprime(f+1))/2)(n!):

%p seq(a(n), n=3..70); # _Alois P. Heinz_, Jan 09 2021

%t a[n_] := (NextPrime[n!, 1] - NextPrime[n!, -1])/2; Array[a, 70, 3]

%o (PARI) a(n) = (nextprime(n!+1) - precprime(n!-1))/2; \\ _Michel Marcus_, Jan 11 2021

%o (Python)

%o from sympy import factorial, nextprime, prevprime

%o def A340013(n):

%o f = factorial(n)

%o return (nextprime(f)-prevprime(f))//2 # _Chai Wah Wu_, Jan 23 2021

%Y Cf. A000142, A002981, A006990, A033932, A033933, A037151, A054588, A058054, A073308.

%K nonn

%O 3,2

%A _Robert G. Wilson v_, Jan 09 2021