A359396 a(n) is the least k such that k^j+2 is prime for j = 1 to n but not n+1.
5, 9, 105, 3, 909, 4995825, 28212939
Offset: 1
Examples
a(4) = 3 because 3^1 + 2 = 5, 3^2 + 2 = 11, and 3^3 + 2 = 29 and 3^4 + 2 = 83 are prime but 3^5 + 2 = 245 is not.
Crossrefs
Cf. A087576.
Programs
-
Maple
f:= proc(n) local j; for j from 1 do if not isprime(n^j+2) then return j-1 fi od end proc: V:= Vector(7): V[1]:= 5: count:= 1: for k from 3 by 6 while count < 7 do v:= f(k); if v > 0 and V[v] = 0 then V[v]:= k; count:= count+1 fi od: convert(V,list);
-
Python
from sympy import isprime from itertools import count, islice def f(k): j = 1 while isprime(k**j + 2): j += 1 return j-1 def agen(): adict, n = dict(), 1 for k in count(2): v = f(k) if v not in adict: adict[v] = k while n in adict: yield adict[n]; n += 1 print(list(islice(agen(), 5))) # Michael S. Branicky, Jan 09 2023
Comments