A343717 a(n) is the smallest number that yields a prime when appended to n!.
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
Examples
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.
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
Programs
-
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 *)
-
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
-
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
Comments