%I #5 Aug 23 2019 14:10:26
%S 1,1,1,2,1,1,3,1,2,1,4,1,2,2,1,5,1,2,3,2,1,6,1,2,3,3,2,1,7,1,2,3,4,3,
%T 2,1,8,1,2,3,4,4,3,2,1,9,1,2,3,4,5,4,3,2,1,10,1,2,3,4,5,5,4,3,2,1,11,
%U 1,2,3,4,5,6,5,4,3,2,1,12,1,2,3,4,5,6,6,5,4,3,2,1,13,1,2,3,4,5,6,7,6,5
%N Distance from n to closest triangular number that is different from n.
%H <a href="/index/Di#distance_to_the_nearest">Index entries for sequences related to distance to nearest element of some set</a>
%t a[n_] := Module[{k = 1}, While[! IntegerQ[Sqrt[8 (n + k) + 1]] && ! IntegerQ[Sqrt[8 (n - k) + 1]], k++]; k]; Table[a[n], {n, 0, 100}]
%Y Cf. A000217, A053188, A053616, A066635.
%K nonn
%O 0,4
%A _Ilya Gutkovskiy_, Aug 22 2019