%I #26 Aug 07 2022 13:35:40
%S 0,0,1,1,2,1,3,1,4,4,5,1,6,1,7,7,8,1,9,1,10,10,11,1,12,11,13,13,14,1,
%T 15,1,16,16,17,16,18,1,19,19,20,1,21,1,22,22,23,1,24,22,25,25,26,1,27,
%U 26,28,28,29,1,30,1,31,31,32,31,33,1,34,34,35,1,36,1,37,37,38,36,39,1,40,40
%N a(0) = a(1) = 0, for n >= 2, a(n) = number of steps of iteration of {r - (smallest prime divisor of r)} needed to reach 0 starting at r = n.
%C See A005843 and A175127 for the smallest and greatest numbers m such that a(m) = k for k >= 2.
%H Antti Karttunen, <a href="/A175126/b175126.txt">Table of n, a(n) for n = 0..16384</a>
%F a(2n) = n >= 2; a(p) = 1 for p = prime.
%F a(n) = 0 if n<=1, else a(n) = 1+a(A046666(n)). - _R. J. Mathar_, Mar 11 2010
%F a(n) = (n-lpf(n))/2 + 1 for n > 1, lpf = A020639. - _Jianing Song_, Aug 07 2022
%e Example (a(6)=3): 6-2=4, 4-2=2, 2-2=0; iterations has 3 steps.
%e a(25) = 11, as we have 25 -> 20 -> 18 -> 16 -> 14 -> 12 -> 10 -> 8 -> 6 -> 4 -> 2 -> 0, in total eleven steps to reach zero. - _Antti Karttunen_, Aug 22 2019
%p Contribution from _R. J. Mathar_, Mar 11 2010: (Start)
%p A020639 := proc(n) min(op(numtheory[factorset](n))) ; end proc:
%p A046666 := proc(n) n-A020639(n) ; end proc:
%p A175126 := proc(n) local a; if n = 1 then 0; elif n = 0 then 0; else 1+procname(A046666(n)) ; end if; end proc:
%p seq(A175126(n),n=1..100) ; (End)
%t stps[n_]:=Length[NestWhileList[#-FactorInteger[#][[1,1]]&,n,#>0&]]-1; Join[{0},Rest[Array[stps,90]]] (* _Harvey P. Dale_, Aug 15 2012 *)
%o (PARI)
%o A020639(n) = if(1==n, n, factor(n)[1, 1]);
%o A175126(n) = if(n<2,0,1+A175126(n-A020639(n))); \\ _Antti Karttunen_, Aug 22 2019
%o (PARI) a(n) = if(n>1, (n-factor(n)[1, 1])/2 + 1, 0) \\ _Jianing Song_, Aug 07 2022
%Y Cf. A020639, A046666, A309892.
%Y From a(2) on, one more than A046667.
%K nonn,easy
%O 0,5
%A _Jaroslav Krizek_, Feb 15 2010
%E Corrected A-number typo in the comment - _R. J. Mathar_, Mar 11 2010
%E Extended beyond a(30) by _R. J. Mathar_, Mar 11 2010
%E Term a(0) = 0 prepended by _Antti Karttunen_, Aug 22 2019