%I #62 Feb 22 2023 09:13:57
%S 1,1,1,1,5,7,7,11,23,17,11,1,29,67,19,43,23,31,37,89,29,31,31,97,131,
%T 41,59,1,67,223,107,127,79,37,97,61,131,1,43,97,53,1,97,71,47,239,101,
%U 233,53,83,61,271,53,71,223,71,149,107,283,293,271,769,131,271
%N Least positive m such that n! + m is prime.
%C Conjecture: No term is a composite number. a(n) is a prime > 3*prime(k), where k is such that prime(k) < n <= prime(k+1). - _Amarnath Murthy_, Apr 07 2004
%C Terms after n = 2000 in the b-file correspond to Fermat and Lucas PRP. - _Phillip Poplin_, Oct 12 2019
%H Phillip Poplin, <a href="/A033932/b033932.txt">Table of n, a(n) for n = 0..4000</a> (first 501 terms from T. D. Noe, then up to n=2000 from Hans Havermann)
%H Antonín Čejchan, Michal Křížek, and Lawrence Somer, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL25/Krizek/krizek3.html">On Remarkable Properties of Primes Near Factorials and Primorials</a>, Journal of Integer Sequences, Vol. 25 (2022), Article 22.1.4.
%H <a href="/index/Fa#factorial">Index entries for sequences related to factorial numbers</a>
%F a(n) = A151800(n!) - n!. - _Max Alekseyev_, Jul 23 2014
%p a:= n-> (f-> nextprime(f)-f)(n!):
%p seq(a(n), n=0..70); # _Alois P. Heinz_, Feb 22 2023
%t a[n_] := (an = 1; While[ !PrimeQ[n! + an], an++]; an); Table[a[n], {n, 0, 63}] (* _Jean-François Alcover_, Dec 05 2012 *)
%t NextPrime[#]-#&/@(Range[0,70]!) (* _Harvey P. Dale_, May 18 2014 *)
%o (PARI) for(n=0,70, k=1; while(!isprime(n!+k), k++); print1(k,","))
%o (PARI) a(n) = nextprime(n!+1) - n!; \\ _Michel Marcus_, Dec 25 2020
%o (Python)
%o from sympy import factorial, nextprime
%o def a(n): fn = factorial(n); return nextprime(fn) - fn
%o print([a(n) for n in range(64)]) # _Michael S. Branicky_, May 22 2022
%Y Cf. A000142, A002981, A033933, A037151, A037153, A056752, A053714, A151800.
%K nice,nonn
%O 0,5
%A _Jeff Burch_
%E More terms from _Jud McCranie_
%E a(21) onwards from _Wouter Meeussen_
%E Better description from _Rick L. Shepherd_, Nov 06 2002