OFFSET
0,3
COMMENTS
Appending to n! any number k <= n yields a multiple of k; that multiple cannot be prime except at k=1, so, for every n, a(n)=1 or a(n) > n.
a(n) = 1 iff n = 0 or n is in A024912.
See A068695 for a proof that a(n) always exists. - Felix Fröhlich, May 18 2021
If a(n) is composite, then a(n) > 2n. - Michael S. Branicky, May 18 2021
LINKS
Lucas A. Brown, Table of n, a(n) for n = 0..2630 (terms 0..1000 from Michael S. Branicky).
Michael S. Branicky, Python program for b-file and A343718, A343719
EXAMPLE
n=1: 1! = 1; appending a 1 yields 11, a prime, so a(1)=1.
n=2: 2! = 2; appending a 1 yields 21 = 3*7, and appending a 2 yields 22 = 2*11, but appending a 3 yields 23 (a prime), so a(2)=3.
n=19: 19! = 121645100408832000; appending any number < 103 yields a composite, but 121645100408832000103 is a prime, so a(19)=103.
MAPLE
a:= proc(n) option remember; local k, t; t:= n!;
for k while not isprime(parse(cat(t, k))) do od; k
end:
seq(a(n), n=0..62); # Alois P. Heinz, May 17 2021
MATHEMATICA
Array[Block[{m = #!, k = 0}, While[! PrimeQ[10^If[k == 0, 1, IntegerLength[k]]*m + k], k++]; k] &, 62] (* Michael De Vlieger, May 17 2021 *)
snp[n_]:=Module[{nf=n!, c=1}, While[!PrimeQ[nf*10^IntegerLength[c]+c], c++]; c]; Array[snp, 70, 0] (* Harvey P. Dale, Oct 17 2024 *)
PROG
(Python) # see link for faster program producing b-file
from sympy import factorial, isprime
def a(n):
start = str(factorial(n))
end = 1
while not isprime(int(start + str(end))): end += 2
return end
print([a(n) for n in range(63)]) # Michael S. Branicky, May 17 2021
(PARI) for(n=0, 62, my(f=digits(n!)); forstep(k=1, oo, 2, my(p=fromdigits(concat(f, digits(k)))); if(ispseudoprime(p), print1(k, ", "); break))) \\ Hugo Pfoertner, May 18 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Jon E. Schoenfield, May 17 2021
STATUS
approved