OFFSET
1,3
COMMENTS
The maximum of a(n)/n appears to converge to sqrt(2)/2 (A010503), i.e. n*(n+1)/2 seems not more than n*sqrt(2)/2 distant from a square.
Some values don't seem to be in the sequence (checked up to n=10^7): 7,18,23,31,37,38...
Those values k are not in the sequence because the Pell-type equations x^2 - 8*y^2 = 8*k+1 and x^2 - 8*y^2 = -8*k+1 have no solutions. - Robert Israel, Apr 08 2019
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
MATHEMATICA
dns[n_]:=Module[{a=Floor[Sqrt[n]]^2, b=Ceiling[Sqrt[n]]^2}, Min[n-a, b-n]]; dns/@Accumulate[Range[90]] (* Harvey P. Dale, Nov 07 2016 *)
PROG
(PARI) m=0; for(n=1, 100, t=n*(n+1)/2; s=sqrtint(t); d=min(t-s^2, (s+1)^2-t); print1(d, ", "))
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Ralf Stephan, Sep 14 2013
STATUS
approved