%I #17 Apr 06 2021 20:25:34
%S 2,6,2,20,2,42,2,6,2,110,2,156,2,6,2,272,2,342,2,6,2,506,2,10,2,6,2,
%T 812,2,930,2,6,2,20,2,1332,2,6,2,1640,2,1806,2,6,2,2162,2,28,2,6,2,
%U 2756,2,10,2,6,2,3422,2,3660,2,6,2,20,2,4422,2,6,2,4970,2,5256,2,6,2,14,2,6162
%N The minimum distance k > 0 such that A020639(n+k) = A020639(n).
%C The sequence has the same records as A002618.
%H Antti Karttunen, <a href="/A174857/b174857.txt">Table of n, a(n) for n = 2..16385</a>
%F If n is even, then a(n) = 2.
%F If n = 3k and A020639(k) >= 3, then a(n) = 6.
%F If n is prime, then a(n) = A036689(n).
%p A174857 := proc(n) local k,aref ; aref := A020639(n) ; for k from 1 do if A020639(n+k) = aref then return k; end if; end do: end proc:
%p seq(A174857(n),n=2..80) ; # _R. J. Mathar_, Dec 07 2010
%t Block[{s = Array[FactorInteger[#][[1, 1]] &, 10^4]}, Array[If[EvenQ[#], 2, Block[{k = 1, n = s[[#]]}, While[n != s[[# + k]], k++; If[# + k > Length[s], AppendTo[s, FactorInteger[# + k][[1, 1]] ]] ]; k]] &, 78, 2]] (* _Michael De Vlieger_, Apr 06 2021 *)
%o (PARI)
%o A020639(n) = if(1==n, n, factor(n)[1, 1]);
%o A174857(n) = if(isprime(n), (n-1)*n, my(spf=A020639(n)); for(k=1,oo,if(A020639(n+k)==spf,return(k)))); \\ _Antti Karttunen_, Apr 06 2021
%Y Cf. A020639, A002618, A036689, A174869.
%K nonn
%O 2,1
%A _Vladimir Shevelev_, Mar 31 2010