%I #32 May 03 2017 17:29:10
%S 2,3,7,5,29,7,11,17,13,11,47,13,17,23,19,17,53,19,23,29,37,23,59,73,
%T 29,107,31,29,173,31,47,41,37,43,71,37,41,47,43,41,173,43,47,53,61,47,
%U 83,73,53,59,67,53,89,79,59,137,61,59,317,61,97,71,67,73,101,67,71,149,73,71
%N Least prime of the form x^2 + n*y^2 with x>0 and y>0.
%C Neither x nor y can be zero because the remaining part of the form would then be composite.
%C a(n) > n.
%C The differences, d, between a(n) and n are 1, 4, 9, 16, 24, 25, 36, 49, 64, 81, 100, 121, 132, 144, 169, 196, 225, 256, 258, 289, 324, 361, 400, 441, ..., .
%C Not all 'd's are squares, such as 24, 132, 258, 1032, 1167, 1518, 2103, 2472, 2652, 2706, 5793. It is conjectured that this list is complete.
%C d=1 for A006093;
%C d=4 for A172367;
%C d=9 for n: 8, 14, 20, 32, 34, 38, 44, 50, 62, 64, 74, 80, 92, 94, 98, 104, 118, 122, 128, 140, 142, 154, 158, ..., ;
%C d=16 for n: 21, 31, 45, 51, 73, 81, 87, 91, 111, 115, 121, 141, 151, 157, 165, 181, 183, 211, 213, 217, 241, ..., ;
%C d=25 for n: 48, 54, 76, 84, 114, 124, 132, 168, 174, 186, 204, 208, 216, 244, 246, 252, 258, 286, 288, 324, ..., ;
%C d=36 for n: 11, 17, 23, 35, 47, 53, 61, 65, 71, 77, 95, 101, 113, 131, 137, 143, 155, 161, 191, 197, 203, 205, ..., ;
%C d=49 for n: 24, 90, 144, 234, 264, 300, 318, 360, 390, 450, 472, 492, 528, 550, 558, 564, 624, 670, 678, 712, ..., ;
%C and for the nonsquare differences of 24, 132, 258, 1032, 1167, 1518, 2103, 2472, 2652, 2706 and 5793l, their n's are 5, 41, 59, 341, 314, 479, 626, 749, 881, 755 and 1784, respectively.
%C Least n that has as its difference k^2: 1, 3, 8, 21, 48, 11, 24, 117, 26, 139, 120, 29, 294, 201, 134, 621, 468, 179, 792, 1269, 356, 1249, 754, 251, 696, ..., .
%H Charles R Greathouse IV, <a href="/A275115/b275115.txt">Table of n, a(n) for n = 1..10000</a>
%H Zak Seidov, <a href="http://zak08.livejournal.com/28934.html">First ten primes of the form x^2+n*y^2 with x>=0, y>=0, n=1..1000.</a>
%F a(n-1) = n iff n is prime.
%e a(1) = 2 since it equals 1^2+1*1^2;
%e a(2) = 3 since it equals 1^2+2*1^2;
%e a(3) = 7 since it equals 2^2+3*1^2;
%e a(4) = 5 since it equals 1^2+4*1^2;
%e a(5) = 29 since it equals 3^2+5*2^2; etc.
%t f[n_] := Block[{p = NextPrime@ n, y}, While[y = 1; While[p > n*y^2 && !IntegerQ[ Sqrt[p - n*y^2]], y++]; !IntegerQ[ Sqrt[p - n*y^2]], p = NextPrime@ p]; p]; Array[f, 70]
%o (PARI) a(n)=if(n==1, return(2)); my(best,x=1+n%2,t); while(!isprime(best=x^2+n), x += 2); for(y=2,sqrtint((best-2)\n), t=best-n*y^2; if(t<1, return(best)); for(x=1,sqrtint(t), if(isprime(t=x^2+n*y^2) && t<best, best=t))); best \\ _Charles R Greathouse IV_, Jul 17 2016
%Y Cf. A002350, A232174, A212602, A212603, A212604, A212605, A244030, A244031, A006093, A172367.
%K nonn
%O 1,1
%A _Zak Seidov_ and _Robert G. Wilson v_, Jul 17 2016