%I #11 Dec 17 2017 03:06:26
%S 0,0,1,0,1,0,4,1,2,0,9,0,2,1,1,0,1,0,4,1,1,0,17,1,2,5,1,0,8,0,11,6,1,
%T 2,7,0,73,1,4,0,1,0,13,2,5,0,8,17,2,1,2,0,2,1,18,2,1,0,1,0,2,1,114,4,
%U 5,0,15,4,1,0,1,0,4,2,1,2,1,0,5,1,5,0,2,2,9,2,4,0,1,1,2,23,7,2,12,0,12,2,1
%N a(n) = smallest k such that n*(n+1)*(n+2)...(n+k) + 1 is prime, or -1 if no prime of such form exists.
%C a(n) = 0 iff n+1 is prime.
%C Since rather large numbers (up to 238 digits) are encountered in the computation, the Pocklington-Lehmer "P-1" primality test is used, as implemented in PARI 2.1.3.
%H Antti Karttunen, <a href="/A087565/b087565.txt">Table of n, a(n) for n = 1..522</a>
%e 7+1 = 8, 7*8+1 = 57, 7*8*9+1 = 505, 7*8*9*10+1 = 5041 are all composite, but 7*8*9*10*11 + 1 = 55441 is prime, so a(7) = 4,
%t Array[If[PrimeQ@ #, 0, Block[{k = 1}, While[! PrimeQ[Pochhammer[# - 1, k + 1] + 1], k++]; k]] &, 99, 2] (* _Michael De Vlieger_, Dec 16 2017 *)
%o (PARI) for(n=1,100,k=0; m=n; while(!isprime(m+1,1),k++; m=m*(n+k)); print1(k,","))
%Y Cf. A087564, A087566.
%K nonn
%O 1,7
%A _Amarnath Murthy_, Sep 15 2003
%E Edited and extended by _Klaus Brockhaus_, Sep 17 2003
%E Escape-clause added to the definition by _Antti Karttunen_, Dec 16 2017