login
Distance from n to closest squarefree number that is different from n.
0

%I #5 Aug 23 2019 14:10:18

%S 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,1,1,1,1,1,3,1,1,1,1,1,1,1,

%T 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,

%U 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,1,1,1,1,2,1,2,1

%N Distance from n to closest squarefree 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[! SquareFreeQ[n + k] && ! SquareFreeQ[n - k], k++]; k]; Table[a[n], {n, 0, 100}]

%Y Cf. A005117, A051700, A080733, A316190.

%K nonn

%O 0,18

%A _Ilya Gutkovskiy_, Aug 22 2019