login
Nonnegative integer whose square is the closest square to prime(n).
2

%I #27 May 14 2020 16:54:52

%S 1,2,2,3,3,4,4,4,5,5,6,6,6,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,10,11,11,

%T 11,12,12,12,12,13,13,13,13,13,13,14,14,14,14,15,15,15,15,15,15,16,16,

%U 16,16,16,16,17,17,17,17,18,18,18,18,18,18,19,19,19,19,19,19,19,20,20,20

%N Nonnegative integer whose square is the closest square to prime(n).

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

%F a(n) = sqrt(A246934(n)).

%t ns[n_]:=Module[{s=Sqrt[n],a,b},a=Floor[s];b=Ceiling[s];If[n-a^2<= b^2- n,a,b]]; ns/@Prime[Range[80]]

%t Sqrt[#]&/@With[{s=Range[20]^2},Table[Nearest[s,p],{p,Prime[ Range[ PrimePi[ Max[s]]]]-1}]]//Flatten (* _Harvey P. Dale_, May 14 2020 *)

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

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

%Y Cf. A000040, A246934.

%K nonn

%O 1,2

%A _Zak Seidov_, Oct 03 2014