login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A079666
Least k such that the distance from k^2 to closest prime = n or zero if no k exists.
1
1, 3, 8, 17, 12, 11, 18, 51, 200, 59, 238, 41, 276, 165, 104, 281, 214, 397, 348, 159, 650, 305, 778, 923, 2242, 1155, 1090, 911, 822, 1871, 1280, 1099, 1516, 3253, 2578, 5849, 3538, 693, 4010, 1937, 1284, 5095, 3212, 2011, 6268, 6331, 2160, 1943, 12470, 13443, 12836, 7405, 25428, 7115, 22596, 10873
OFFSET
1,2
COMMENTS
From Robert Israel, Jan 03 2017: (Start)
For n > 1, a(n) == n (mod 2) unless it is 0.
a(191) > 3*10^7 if it is not 0. (End)
LINKS
MAPLE
N:= 100: # for a(1)..a(N)
R[1]:= 1: count:= 1:
for k from 3 while count < N do
d:= min(nextprime(k^2)-k^2, k^2-prevprime(k^2));
if d <= N and not assigned(R[d]) then R[d]:= k; count:= count+1 fi
od:
seq(R[i], i=1..N); # Robert Israel, Jan 03 2017
PROG
(PARI) a(n)=if(n<0, 0, s=1; while(abs(n-min(abs(precprime(s^2)-s^2), abs(nextprime(s^2)-s^2)))>0, s++); s)
CROSSREFS
Sequence in context: A196373 A027291 A048952 * A193684 A308850 A368273
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Jan 26 2003
EXTENSIONS
More terms from Robert Israel, Jan 03 2017
STATUS
approved