OFFSET
1,3
FORMULA
a(n) = A087565(n) + 1. - Filip Zaludek, Dec 16 2016
EXAMPLE
a(2)=1 because 2+1=3 is a prime. a(3)=2 because 3+1=4 is not a prime, but 3*4+1=13 is a prime. a(9)=3 because neither 9+1=10 nor 9*10+1=91=13*7 is a prime, but 9*10*11+1=991 is.
MATHEMATICA
a[n_] := Block[{}, For[s = n; k = 1, ! PrimeQ[s + 1], s *= n + k; k++ ]; k] Table[a[n], {n, 1, 100}]
(* Second program *)
Table[k = 1; While[! PrimeQ[1 + Pochhammer[n, k]], k++]; k, {n, 99}] (* Michael De Vlieger, Dec 17 2016 *)
PROG
(PARI) a(n)=my(N=n, k=n); while(!ispseudoprime(N+1), N*=k++); k-n+1 \\ Charles R Greathouse IV, May 15 2013
CROSSREFS
KEYWORD
nonn
AUTHOR
Cheng Zhang (cz1(AT)rice.edu), Jan 26 2010
STATUS
approved