OFFSET
0,1
COMMENTS
Is 19 the largest n such that a(n) = 2? There are none for 19 < n <= 600. - Robert Israel, Jan 16 2017
LINKS
Robert Israel, Table of n, a(n) for n = 0..466
EXAMPLE
a(7) = 2521 because 7!/2! + 1 = 2521 is prime, whereas 7!/1! + 1 = 5041 = 71^2 is composite;
a(19) = 2 because the only prime of the form 19!/k! + 1 is 19!/19! + 1 = 2.
MAPLE
f:= proc(n) local k, x;
x:= n!;
for k from 2 do
if isprime(x+1) then return x+1 fi;
x:= x/k;
od
end proc:
map(f, [$0..40]); # Robert Israel, Jan 16 2017
MATHEMATICA
a[n_] := Module[{k, x}, x = n!; For[k = 2, True, k++, If[PrimeQ[x+1], Return[x+1]]; x = x/k]];
Table[a[n], {n, 0, 40}] (* Jean-François Alcover, Feb 08 2023, after Robert Israel *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Apr 01 2004
EXTENSIONS
Corrected and extended by Hugo Pfoertner, Apr 06 2004
STATUS
approved