OFFSET
1,3
FORMULA
A358790((a(n)-1)/2) = prime(n) for n > 1.
EXAMPLE
a(4) = 15 because prime(4) = 7 and (15^2 + 7^2)/2 = 137 is prime while (15^2 + p^2)/2 is not prime for primes p < 7, and 15 is the least number that works.
MAPLE
g:= proc(n) local s, p;
s:= n^2; p:= 2;
do
p:= nextprime(p);
if isprime((s+p^2)/2) then return p fi
od
end proc:
N:= 100: # for a(1)..a(N)
M:= ithprime(N): V:= Vector(M, -1):
count:= 1: V[2]:= 0:
for n from 1 by 2 while count < N do
v:= g(n); if v <= M and V[v] = -1 then V[v]:= n; count:= count+1 fi;
od:
seq(V[ithprime(i)], i=1..N);
MATHEMATICA
a[n_] := Module[{p = Prime[n], k = 0}, While[! PrimeQ[(k^2 + p^2)/2] || AnyTrue[Prime[Range[n - 1]], PrimeQ[(k^2 + #^2)/2] &], k++]; k]; Array[a, 50] (* Amiram Eldar, Dec 01 2022 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
J. M. Bergot and Robert Israel, Dec 01 2022
STATUS
approved