OFFSET
1,1
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..29
C. Caldwell's The Top Twenty, Factorial Primes.
R. Mestrovic, Euclid's theorem on the infinitude of primes: a historical survey of its proofs (300 BC--2012) and another new proof, arXiv preprint arXiv:1202.3670 [math.HO], 2012-2018. - From N. J. A. Sloane, Jun 13 2012
Wikipedia, Factorial prime.
EXAMPLE
3! + 1 = 7; 7! - 1 = 5039.
39916801 is a term because 11! + 1 is prime.
MATHEMATICA
t = {}; Do[ If[PrimeQ[n! - 1], AppendTo[t, n! - 1]]; If[PrimeQ[n! + 1], AppendTo[t, n! + 1]], {n, 50}]; t (* Robert G. Wilson v *)
Union[Select[Range[50]!-1, PrimeQ], Select[Range[50]!+1, PrimeQ]] (Noe)
fp[n_] := Module[{nf=n!}, Select[{nf-1, nf+1}, PrimeQ]]; Flatten[ Table[ fp[i], {i, 50}]] (* Harvey P. Dale, Dec 18 2010 *)
Select[Flatten[#+{-1, 1}&/@(Range[50]!)], PrimeQ] (* Harvey P. Dale, Apr 08 2019 *)
PROG
(Python)
from itertools import count, islice
from sympy import isprime
def A088054_gen(): # generator of terms
f = 1
for k in count(1):
f *= k
if isprime(f-1):
yield f-1
if isprime(f+1):
yield f+1
CROSSREFS
KEYWORD
easy,nice,nonn
AUTHOR
Christopher M. Tomaszewski (cmt1288(AT)comcast.net), Nov 02 2003
EXTENSIONS
Corrected by Paul Muljadi, Oct 11 2005
More terms from Robert G. Wilson v and T. D. Noe, Oct 12 2005
STATUS
approved