cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A343717 a(n) is the smallest number that yields a prime when appended to n!.

This page as a plain text file.
%I A343717 #47 Oct 17 2024 10:31:12
%S A343717 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,
%T A343717 31,37,59,41,53,41,47,1,41,149,37,53,73,337,1,103,151,293,47,107,509,
%U A343717 127,71,167,197,167,149,67,163,139,251,59,107,241,331,269,1,149
%N A343717 a(n) is the smallest number that yields a prime when appended to n!.
%C A343717 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.
%C A343717 a(n) = 1 iff n = 0 or n is in A024912.
%C A343717 See A068695 for a proof that a(n) always exists. - _Felix Fröhlich_, May 18 2021
%C A343717 If a(n) is composite, then a(n) > 2n. - _Michael S. Branicky_, May 18 2021
%H A343717 Lucas A. Brown, <a href="/A343717/b343717.txt">Table of n, a(n) for n = 0..2630</a> (terms 0..1000 from Michael S. Branicky).
%H A343717 Michael S. Branicky, <a href="/A343717/a343717.py.txt">Python program for b-file and A343718, A343719</a>
%F A343717 a(n) = A068695(n!) = A068695(A000142(n)).
%e A343717 n=1: 1! = 1; appending a 1 yields 11, a prime, so a(1)=1.
%e A343717 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.
%e A343717 n=19: 19! = 121645100408832000; appending any number < 103 yields a composite, but 121645100408832000103 is a prime, so a(19)=103.
%p A343717 a:= proc(n) option remember; local k, t; t:= n!;
%p A343717       for k while not isprime(parse(cat(t, k))) do od; k
%p A343717     end:
%p A343717 seq(a(n), n=0..62);  # _Alois P. Heinz_, May 17 2021
%t A343717 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 *)
%t A343717 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 *)
%o A343717 (Python) # see link for faster program producing b-file
%o A343717 from sympy import factorial, isprime
%o A343717 def a(n):
%o A343717   start = str(factorial(n))
%o A343717   end = 1
%o A343717   while not isprime(int(start + str(end))): end += 2
%o A343717   return end
%o A343717 print([a(n) for n in range(63)]) # _Michael S. Branicky_, May 17 2021
%o A343717 (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
%Y A343717 Cf. A000040, A000142, A024912, A033932, A068695, A095194, A343718, A343719.
%K A343717 nonn,base
%O A343717 0,3
%A A343717 _Jon E. Schoenfield_, May 17 2021