Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #23 Sep 03 2023 15:10:41
%S 0,1,10,60,90,101,120,380,450,505,807,1020,1070,1303,1450,3810,10020,
%T 10404,10560,16056,16200,18088,20322,20580,35790,79000,80088,90877,
%U 243700,279509,330832,374330,380038,903655,1002404,1005064,1020828
%N Smallest number with persistence n for the sort-and-subtract-sequence.
%C Sort the digits of an integer and subtract the result from the original. Continue with the result until you reach 0. The sequence gives the least integer that needs n steps to reach 0.
%H David W. Wilson and Reinhard Zumkeller, <a href="/A065641/b065641.txt">Table of n, a(n) for n = 0..100</a> (a(n) for n = 1..55 from Reinhard Zumkeller).
%e 60 is the smallest number that needs 3 steps to reach 0: 60 -> 60 - 06 = 54 -> 54 - 45 = 9 -> 9 - 9 = 0, hence a(3) = 60.
%t Persist[n_] := Length[NestWhileList[# - FromDigits[Sort[IntegerDigits[#]]] &, n, # != 0 &]] - 1; nn = 20; t = Table[0, {nn}]; cnt = 0; k = 0; While[cnt < nn, k++; c = Persist[k]; If[c <= nn && t[[c]] == 0, t[[c]] = k; cnt++]]; t (* _Harvey P. Dale_, Mar 24 2011 *)
%t persist[n_]:=Length[NestWhileList[#-FromDigits[Sort[IntegerDigits[#]]]&,n,#!=0&]]-1; Module[ {nn=103*10^4,tbl},tbl=Table[{n,persist[n]},{n,0,nn}];DeleteDuplicates[ tbl,GreaterEqual[ #1[[2]],#2[[2]]]&]][[;;,1]] (* _Harvey P. Dale_, Sep 03 2023 *)
%o (Haskell)
%o import Data.List (elemIndex)
%o import Data.Maybe (fromJust)
%o a065641 n = a065641_list !! (n-1)
%o a065641_list = map (fromJust . (`elemIndex` a193582_list)) [1..]
%o -- _Reinhard Zumkeller_,Aug 10 2011
%Y Cf. A004185, A193582.
%K nonn,base,nice
%O 0,3
%A Ulrich Schimke (ulrschimke(AT)aol.com), Dec 03 2001
%E Added a(0) = 0. _David W. Wilson_, Jan 08 2017