login
The closest square to n-th prime.
2

%I #13 Oct 02 2014 22:45:51

%S 1,4,4,9,9,16,16,16,25,25,36,36,36,49,49,49,64,64,64,64,81,81,81,81,

%T 100,100,100,100,100,121,121,121,144,144,144,144,169,169,169,169,169,

%U 169,196,196,196,196,225,225,225,225,225,225,256,256,256,256,256,256,289,289,289,289

%N The closest square to n-th prime.

%H Zak Seidov, <a href="/A246934/b246934.txt">Table of n, a(n) for n = 1..1000</a>

%e a(5) = 9 because 5th prime is 11, and 11-9<16-11, that is 9 is the closest square to 11.

%o (PARI){forprime (p = 2, 300, a = sqrtint (p); b = (a + 1)^2; a = a^2;

%o s = if (b - p > p - a, a, b); print1 (s ", "))}

%K nonn

%O 1,2

%A _Zak Seidov_, Oct 02 2014