Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #15 Jan 11 2023 08:48:08
%S 5,9,105,3,909,4995825,28212939
%N a(n) is the least k such that k^j+2 is prime for j = 1 to n but not n+1.
%C All terms are odd, and all except a(1) = 5 are divisible by 3.
%C The generalized Bunyakovsky conjecture implies that a(n) exists for all n.
%C a(8) > 10^10.
%C a(8) > 10^11. - _Lucas A. Brown_, Jan 11 2023
%e 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.
%p f:= proc(n) local j;
%p for j from 1 do
%p if not isprime(n^j+2) then return j-1 fi
%p od
%p end proc:
%p V:= Vector(7): V[1]:= 5: count:= 1:
%p for k from 3 by 6 while count < 7 do
%p v:= f(k);
%p if v > 0 and V[v] = 0 then V[v]:= k; count:= count+1 fi
%p od:
%p convert(V,list);
%o (Python)
%o from sympy import isprime
%o from itertools import count, islice
%o def f(k):
%o j = 1
%o while isprime(k**j + 2): j += 1
%o return j-1
%o def agen():
%o adict, n = dict(), 1
%o for k in count(2):
%o v = f(k)
%o if v not in adict: adict[v] = k
%o while n in adict: yield adict[n]; n += 1
%o print(list(islice(agen(), 5))) # _Michael S. Branicky_, Jan 09 2023
%Y Cf. A087576.
%K nonn,more
%O 1,1
%A _Robert Israel_, Dec 29 2022