Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #18 Oct 14 2020 16:43:22
%S 4,1,3,6,2,5,1,4,8,3,7,2,6,1,5,10,4,9,3,8,2,7,1,6,12,5,11,4,10,3,9,2,
%T 8,1,7,14,6,13,5,12,4,11,3,10,2,9,1,8,16,7,15,6,14,5,13,4,12,3,11,2,
%U 10,1,9,18,8,17,7,16,6,15,5,14,4,13,3,12,2,11,1,10,20,9,19,8,18,7,17,6,16,5,15,4,14,3,13,2,12,1,11,22
%N Smallest positive integer m such that n + 2m is a square.
%H Charles R Greathouse IV, <a href="/A256243/b256243.txt">Table of n, a(n) for n = 1..10000</a>
%F 1 <= a(n) <= 2*sqrt(n) + 2. - _Charles R Greathouse IV_, Mar 23 2015
%F a(n) = (1/4)*(6*floor(sqrt(n)) + 2*floor(sqrt(n))^2 + (2*floor(sqrt(n)) + 3)*(-1)^(n - floor(sqrt(n))) - 2*n + 5). - _Ridouane Oudra_, Oct 09 2020
%e 1 + 2*4 = 9 = 3^2 so a(1) = 4.
%e 2 + 2*1 = 4 = 2^2, so a(2) = 1.
%e 3 + 2*3 = 9 = 3^2, so a(3) = 3.
%t Table[m = 1; While[! IntegerQ[Sqrt[n + 2*m]], m++]; m, {n, 100}] (* _Michael De Vlieger_, Mar 20 2015 *)
%o (PARI) a(n)=m=1;while(!issquare(n+2*m),m++);m
%o vector(100,n,a(n)) \\ _Derek Orr_, Mar 22 2015
%o (PARI) a(n)=my(s=sqrtint(n)); (if((s-n)%2,s+1,s+2)^2-n)/2 \\ _Charles R Greathouse IV_, Mar 23 2015
%Y Cf. A256244, A080883.
%K nonn,easy
%O 1,1
%A _Zak Seidov_, Mar 20 2015