A229118 Distance from the n-th triangular number to the nearest square.
0, 1, 2, 1, 1, 4, 3, 0, 4, 6, 2, 3, 9, 5, 1, 8, 9, 2, 6, 14, 6, 3, 13, 11, 1, 10, 17, 6, 6, 19, 12, 1, 15, 19, 5, 10, 26, 12, 4, 21, 20, 3, 15, 29, 11, 8, 28, 20, 0, 21, 30, 9, 13, 36, 19, 4, 28, 30, 6, 19, 42, 17, 9, 36, 29, 2, 26, 42, 14, 15, 45, 27, 3, 34, 41, 10, 22, 55, 24, 9, 43, 39, 5, 30, 55, 20, 16, 53, 36, 1
Offset: 1
Links
- Harvey P. Dale, Table of n, a(n) for n = 1..1000
Programs
-
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 *)
-
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, ","))
Comments