OFFSET
1,2
COMMENTS
a(n) = n for n = 1, 2, 3, 6, 13, 25, 26, 27, 29, 45, 48, 53, 59, 80, 85, ...
If a(n) = 1, then the next entry > 1 is a(m) = m for the least m > n such that 1 + m * Product_{j=1..n-1} a_j is prime. By Dirichlet's theorem such m exists. - Robert Israel, Aug 07 2017
LINKS
Iain Fox, Table of n, a(n) for n = 1..2000
MAPLE
A[1]:= 1: P:= 1:
for n from 2 to 200 do
for k from n to 0 by -1 do
if isprime(1+k*P) then
A[n]:= k;
P:= P*k;
break
fi
od;
od:
seq(A[i], i=1..200); # Robert Israel, Aug 07 2017
MATHEMATICA
p = 1; Table[t = SelectFirst[Range[n, 1, -1], PrimeQ[1 + p #] &]; p *= t; t, {n, 85}] (* Giovanni Resta, Aug 08 2017 *)
PROG
(Python)
from sympy import isprime
A=[0, 1]
p=1
for n in range(2, 201):
for k in range(n, -1, -1):
if isprime(1 + k*p):
A.append(k)
p*=k
break
print(A[1:]) # Indranil Ghosh, Aug 10 2017
(PARI) first(n) = { my(i = 1, res = vector(n)); res[1]=1; for(x=2, n, forstep(k=x, 0, -1, if(ispseudoprime(1+k*i), res[x]=k; i*=k; break()))); res; } \\ Iain Fox, Nov 15 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Thomas Ordowski, Aug 07 2017
EXTENSIONS
More terms from Robert Israel, Aug 07 2017
STATUS
approved