%I #26 Sep 14 2020 11:50:40
%S 0,1,21,31,42,52,73,81,319,391,463,583,2911,3667,6451,8793,9927,
%T 237126,254158,278393,2561363,9398143,9431623,9951265,83543869,
%U 83896381,83935261,2843233127,2847297383,2853748583,2885762663,266998137657,685718563667,688373877587
%N a(n) is the smallest number such that, with f(x) = x - (the product of the digits of x), f(a(n)) reaches a fixed point after n iterations.
%C A fixed point occurs once the function returns a number that contains the digit 0. After that, the product of the digits will be 0, and so subtracting it from the number will be idempotent.
%C This sequence is conceptually similar to A003001, though unlike the latter, it is probably infinite.
%e a(9) = 391 because:
%e 1: 391 - 3*9*1 = 364
%e 2: 364 - 3*6*4 = 292
%e 3: 292 - 2*9*2 = 256
%e 4: 256 - 2*5*6 = 196
%e 5: 196 - 1*9*6 = 142
%e 6: 142 - 1*4*2 = 134
%e 7: 134 - 1*3*4 = 122
%e 8: 122 - 1*2*2 = 118
%e 9: 118 - 1*1*8 = 110
%e After iteration 9, the function becomes idempotent:
%e 10: 110 - 1*1*0 = 110
%e 11: 110 - 1*1*0 = 110
%e 12: 110 - 1*1*0 = 110
%e ...
%e Additionally, 391 is the smallest number with this property. Thus, it is a(9).
%t nmax = 20; tab = ConstantArray[Null, nmax];
%t For[k = 0, k <= 1000000, k++,
%t l=Length@ NestWhileList[#-Times @@ IntegerDigits[#] &,k,UnsameQ[##] &, 2]-2;
%t If[tab[[l+1]] == Null, tab[[l+1]] = k]]; tab (* _Robert Price_, Sep 13 2020 *)
%o (Python)
%o def f(x):
%o prod = 1
%o for digit in str(x):
%o prod *= int(digit)
%o return x - prod
%o def a(n):
%o i = 0
%o iteration = 0
%o while iteration != n:
%o i += 1
%o j = i
%o iteration = 0
%o new_j = f(j)
%o while j != new_j:
%o iteration += 1
%o j = new_j
%o new_j = f(j)
%o return i
%o (PARI) f(m) = m - vecprod(digits(m)) + (m==0);
%o lista(nn) = {my(c, m, t); for(k=0, nn, c=0; m=k; while(m!=(m=f(m)), c++); if(c==t, print1(k, ", "); t++)); } \\ _Jinyuan Wang_, Aug 14 2020
%Y Cf. A003001, A070565.
%K nonn,base
%O 0,3
%A _Alon Ran_, Jul 19 2020
%E a(27)-a(30) from _Jinyuan Wang_, Aug 14 2020
%E a(31)-a(33) added by _Michael S. Branicky_, Aug 29 2020