%I #25 Jul 29 2014 03:41:17
%S 2,2,2,2,0,2,2,0,3,3,0,2,5,0,2,2,0,2,8,0,6,3,0,6,15,0,6,2,0,2,23,0,23,
%T 56,0,15,114,0,14,11,0,3,14,0,29,110,0,21,9,0,53,59,0,6,2,0,3,29,0,71,
%U 21,0,146,17,0,35,2,0,9,6,0,77,41,0,27,176,0,153,21,0,39,32,0,2,314,0,3,5,0,66,44,0,234
%N Least number k > 1 such that k^n + k + 1 is prime, or 0 if no such number exists.
%C Except for a(2), a(n) = 0 if n == 2 mod 3 (A016789).
%C It appears that this is an "if and only if".
%C a(n) = 2 if and only if n is in A057732.
%C 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
%H Robert Israel and Jens Kruse Andersen, <a href="/A245476/b245476.txt">Table of n, a(n) for n = 1..1000</a> (first 640 terms from Robert Israel)
%e 2^9 + 2 + 1 = 515 is not prime. 3^9 + 3 + 1 = 19687 is prime. Thus a(9) = 3.
%p f:= proc(n) local k;
%p if n mod 3 = 2 and n > 2 then return 0 fi;
%p for k from 2 to 10^6 do
%p if isprime(k^n+k+1) then return k fi
%p od:
%p error("no solution found for n = %1",n);
%p end proc:
%p seq(f(n),n=1..100); # _Robert Israel_, Jul 27 2014
%o (PARI) a(n) = if(n>2&&n==Mod(2, 3), return(0)); k=2; while(!ispseudoprime(k^n+k+1), k++); k
%o vector(150, n, a(n)) \\ _Derek Orr_ with corrections and improvements from _Colin Barker_, Jul 23 2014
%Y Cf. A127599, A016789, A057732.
%Y Cf. Numbers n such that n^s + n + 1 is prime: A005097 (s = 1), A002384 (s = 2), A049407 (s = 3), A049408 (s = 4), A075723 (s = 6), A075722 (s = 7), A075720 (s = 9), A075719 (s = 10), A075718 (s = 12), A075717 (s = 13), A075716 (s = 15), A075715 (s = 16), A075714 (s = 18), A075713 (s = 19).
%K nonn
%O 1,1
%A _Derek Orr_, Jul 23 2014
|