login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A343717
a(n) is the smallest number that yields a prime when appended to n!.
3
1, 1, 3, 1, 1, 1, 7, 11, 29, 17, 43, 29, 13, 47, 19, 73, 37, 19, 41, 103, 41, 31, 43, 1, 113, 31, 37, 59, 41, 53, 41, 47, 1, 41, 149, 37, 53, 73, 337, 1, 103, 151, 293, 47, 107, 509, 127, 71, 167, 197, 167, 149, 67, 163, 139, 251, 59, 107, 241, 331, 269, 1, 149
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).
FORMULA
a(n) = A068695(n!) = A068695(A000142(n)).
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
KEYWORD
nonn,base
AUTHOR
Jon E. Schoenfield, May 17 2021
STATUS
approved