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”).
%I #13 Jul 09 2021 22:58:09
%S 2,2,2,0,2,2,0,2,3,0,4,2,0,2,2,0,2,3,0,2,2,0,9,2,0,4,2,0,3,3,0,3,2,0,
%T 15,4,0,2,3,0,2,3,0,3,6,0,4,3,0,2,9,0,3,2,0,3,2,0,2,3,0,2,73,0,12,2,0,
%U 595,2,0,2,4,0,3,2,0,2,2,0,2,7,0,3,30,0,21,3,0,2,2,0,7,67,0,3
%N a(n) is the least integer k > 1 such that n^k + n + 1 is prime, or 0 if there is no such k.
%C a(n) = 0 if n == 1 (mod 3) and n > 1.
%C Conjecture: a(n) > 0 otherwise.
%H Robert Israel, <a href="/A346149/b346149.txt">Table of n, a(n) for n = 1..212</a>
%e a(9) = 3 because 9^3 + 9 + 1 = 739 is prime while 9^2+9+1 is not.
%p f:= proc(n) local i;
%p if n mod 3 = 1 then return 0 fi;
%p for i from 2 do if isprime(n^i+n+1) then return i fi od:
%p end proc:
%p f(1):= 2:
%p map(f, [$1..100]);
%o (PARI) a(n) = if ((n>1) && ((n%3)==1), 0, my(k=2); while (!isprime(n^k+n+1), k++); k); \\ _Michel Marcus_, Jul 07 2021
%o (Python)
%o from sympy import isprime
%o def a(n):
%o if n > 1 and n%3 == 1: return 0
%o k = 2
%o while not isprime(n**k + n + 1): k += 1
%o return k
%o print([a(n) for n in range(1, 96)]) # _Michael S. Branicky_, Jul 08 2021
%K nonn
%O 1,1
%A _J. M. Bergot_ and _Robert Israel_, Jul 07 2021