OFFSET
1,1
COMMENTS
Except for a(2), a(n) = 0 if n == 2 mod 3 (A016789).
It appears that this is an "if and only if".
a(n) = 2 if and only if n is in A057732.
Many terms in the linked table correspond to probable primes. If n == 2 mod 3 then k^2+k+1 divides k^n+k+1. This is why a(n) = 0 if n > 2 and n == 2 mod 3. - Jens Kruse Andersen, Jul 28 2014
LINKS
Robert Israel and Jens Kruse Andersen, Table of n, a(n) for n = 1..1000 (first 640 terms from Robert Israel)
EXAMPLE
2^9 + 2 + 1 = 515 is not prime. 3^9 + 3 + 1 = 19687 is prime. Thus a(9) = 3.
MAPLE
f:= proc(n) local k;
if n mod 3 = 2 and n > 2 then return 0 fi;
for k from 2 to 10^6 do
if isprime(k^n+k+1) then return k fi
od:
error("no solution found for n = %1", n);
end proc:
seq(f(n), n=1..100); # Robert Israel, Jul 27 2014
PROG
(PARI) a(n) = if(n>2&&n==Mod(2, 3), return(0)); k=2; while(!ispseudoprime(k^n+k+1), k++); k
vector(150, n, a(n)) \\ Derek Orr with corrections and improvements from Colin Barker, Jul 23 2014
CROSSREFS
KEYWORD
nonn
AUTHOR
Derek Orr, Jul 23 2014
STATUS
approved