A346149 a(n) is the least integer k > 1 such that n^k + n + 1 is prime, or 0 if there is no such k.
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, 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, 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
Offset: 1
Keywords
Examples
a(9) = 3 because 9^3 + 9 + 1 = 739 is prime while 9^2+9+1 is not.
Links
- Robert Israel, Table of n, a(n) for n = 1..212
Programs
-
Maple
f:= proc(n) local i; if n mod 3 = 1 then return 0 fi; for i from 2 do if isprime(n^i+n+1) then return i fi od: end proc: f(1):= 2: map(f, [$1..100]);
-
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
-
Python
from sympy import isprime def a(n): if n > 1 and n%3 == 1: return 0 k = 2 while not isprime(n**k + n + 1): k += 1 return k print([a(n) for n in range(1, 96)]) # Michael S. Branicky, Jul 08 2021
Comments