%I #17 Jul 16 2019 03:23:07
%S 2,3,5,29,41,389,479,881,1931,3461,3701,7589,9749,26171,153089,405701,
%T 1036829,1354349,1516829,2677289,4790309,4990961,34648631,46214321,
%U 50583209,98999969,305094851,331498961,362822099,4373372351,11037674441,12239355719,16085541359
%N Primes to which a record size square needs to be added to reach another prime.
%C a(1) = 2 and r(1) = 1.
%C For n > 1, a(n) is the smallest prime for which r(n) > r(n-1) exists so that a(n) + r(n)^2 is prime and a(n) + k^2 are composite for 0 < k < r(n).
%C When omitting the squares in the description, the sequence becomes A002386.
%e a(1) = 2; r(1) = 1.
%e a(2) = 3; 3 + 1^2 is composite, but 3 + 2^2 is prime, so r(2) = 2.
%e a(3) = 5; 5 + k^2 is composite for 0 < k < 6, but 5 + 6^2 is prime, so r(3) = 6.
%e The following are primes: 7 + 2^2, 11 + 6^2, 13 + 2^2, 17 + 6^2, 19 + 2^2, 23 + 6^2.
%e a(4) = 29; 29 + k^2 is composite for 0 < k < 12, but 29 + 12^2 is prime: r(4) = 12.
%o (Python)
%o from sympy import isprime, nextprime
%o n, p, r = 0, 0, 0
%o while(True):
%o ....p = nextprime(p) ; k = 1
%o ....while not isprime(p + k**2):
%o ........k += 1
%o ....if k > r:
%o ........n += 1 ; r = k
%o ........print("a({}) = {}".format(n,p))
%o (PARI) f(n) = {k=1; while(!isprime(n+k^2), k++); k;}
%o lista(NN) = {m=0; forprime(p=1, NN, if(f(p)>m, m=f(p);print1(p,", ")))} \\ _Jinyuan Wang_, Jul 15 2019
%Y Cf. A002386, A020495, A065376, A127356, A129314.
%K nonn
%O 1,1
%A _Bert Dobbelaere_, Jul 15 2019
%E a(30)-a(33) from _Giovanni Resta_, Jul 16 2019