OFFSET
3,1
COMMENTS
Analogous to the lesser Fortunate numbers and like them, all entries so far are primes.
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 3..1000
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) >= n. - Seiichi Manyama, Mar 21 2018
EXAMPLE
a(4) = 4!-19 = 24-19 = 5.
MATHEMATICA
PrevPrime[ n_Integer ] := (k=n-1; While[ !PrimeQ[ k ], k-- ]; Return[ k ]); f[ n_Integer ] := (p = n! - 1; q = NextPrime[ p ]; Return[ p - q + 1 ]); Table[ f[ n ], {n, 3, 75} ]
f[n_]:=Module[{nf=n!}, nf-NextPrime[nf-1, -1]]; f/@Range[3, 90] (* Harvey P. Dale, Mar 20 2011 *)
PROG
(PARI) a(n)=my(N=n!); N-precprime(N-3) \\ Charles R Greathouse IV, Jan 28 2018
(Python)
from sympy import factorial, prevprime
def a(n): fn = factorial(n); return fn - prevprime(fn-1)
print([a(n) for n in range(3, 65)]) # Michael S. Branicky, May 22 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
More terms from James A. Sellers, Jul 06 2000
STATUS
approved