login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A087421
Smallest prime >= n!.
3
2, 2, 2, 7, 29, 127, 727, 5051, 40343, 362897, 3628811, 39916801, 479001629, 6227020867, 87178291219, 1307674368043, 20922789888023, 355687428096031, 6402373705728037, 121645100408832089, 2432902008176640029, 51090942171709440031, 1124000727777607680031
OFFSET
0,1
COMMENTS
n! is prime only when n=2. When n>2, for n!+m to be prime, m must be relatively prime to all the numbers from 2 to n. In particular, if m is between 2 and n, then (n!+m) will be divisible by m. Thus a(n) must be either n!+1, or else larger than n!+n.
LINKS
Antonín Čejchan, Michal Křížek, and Lawrence Somer, On Remarkable Properties of Primes Near Factorials and Primorials, Journal of Integer Sequences, Vol. 25 (2022), Article 22.1.4.
FORMULA
a(n) = min { p[i] | p[i]>=n! }, where p[i] is the set of prime numbers.
a(n) = A007918(A000142(n)). - Michel Marcus, Apr 09 2018
EXAMPLE
a(0) = 2 since 0! = 1 and 2 is the smallest prime >= 1.
a(4) = 29 since 4! = 24 and 29 is the smallest prime >= 24.
MATHEMATICA
NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; Table[ NextPrim[n! - 1], {n, 0, 20}] (* Robert G. Wilson v, Oct 25 2003 *)
Join[{2, 2, 2}, NextPrime[Range[3, 25]!]] (* Harvey P. Dale, Feb 23 2011 *)
PROG
(PARI) a(n)=nextprime(n!); \\ R. J. Cano, Apr 08 2018
(Python)
from sympy import factorial, nextprime
def a(n): return nextprime(factorial(n)-1)
print([a(n) for n in range(23)]) # Michael S. Branicky, May 22 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Mitch Cervinka (puritan(AT)planetkc.com), Oct 22 2003
EXTENSIONS
Edited, corrected and extended by Robert G. Wilson v and Ray Chandler, Oct 25 2003
STATUS
approved