login
Smallest prime of the form k*n! - 1.
2

%I #16 Nov 23 2023 11:30:28

%S 2,3,5,23,239,719,5039,201599,1088639,14515199,159667199,479001599,

%T 31135103999,87178291199,2615348735999,188305108991999,

%U 711374856191999,192071211171839999,3649353012264959999,12164510040883199999,2248001455555215359999,2248001455555215359999

%N Smallest prime of the form k*n! - 1.

%H Robert Israel, <a href="/A084730/b084730.txt">Table of n, a(n) for n = 2..447</a>

%F a(n) = A083663(n)*n! - 1 = A038700(n!). - _Robert Israel_, Nov 23 2023

%e a(8) = 161599 = 4*8! - 1 is a prime.

%p f:= proc(n) local w,k;

%p w:= n!;

%p for k from 1 do

%p if isprime(k*w-1) then return k*w-1 fi

%p od

%p end proc:

%p map(f, [$1..30]); # _Robert Israel_, Nov 23 2023

%t Do[k = 1; While[ !PrimeQ[k*n! - 1], k++ ]; Print[k*n! - 1], {n, 2, 20}]

%o (PARI) a(n)=if(n<1,0,k=1; while(isprime(k*n!-1)==0,k++); k*n!-1)

%Y Cf. A083663, A038700.

%K nonn

%O 2,1

%A _Amarnath Murthy_ and Meenakshi Srikanth (menakan_s(AT)yahoo.com), Jun 13 2003

%E Corrected and extended by _Benoit Cloitre_, Jun 14 2003