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”).

A087565
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.
4
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, 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, 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
OFFSET
1,7
COMMENTS
a(n) = 0 iff n+1 is prime.
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.
LINKS
EXAMPLE
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,
MATHEMATICA
Array[If[PrimeQ@ #, 0, Block[{k = 1}, While[! PrimeQ[Pochhammer[# - 1, k + 1] + 1], k++]; k]] &, 99, 2] (* Michael De Vlieger, Dec 16 2017 *)
PROG
(PARI) for(n=1, 100, k=0; m=n; while(!isprime(m+1, 1), k++; m=m*(n+k)); print1(k, ", "))
CROSSREFS
Sequence in context: A331749 A274438 A365387 * A079163 A108536 A232631
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Sep 15 2003
EXTENSIONS
Edited and extended by Klaus Brockhaus, Sep 17 2003
Escape-clause added to the definition by Antti Karttunen, Dec 16 2017
STATUS
approved