OFFSET
0,3
COMMENTS
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.
This sequence is conceptually similar to A003001, though unlike the latter, it is probably infinite.
EXAMPLE
a(9) = 391 because:
1: 391 - 3*9*1 = 364
2: 364 - 3*6*4 = 292
3: 292 - 2*9*2 = 256
4: 256 - 2*5*6 = 196
5: 196 - 1*9*6 = 142
6: 142 - 1*4*2 = 134
7: 134 - 1*3*4 = 122
8: 122 - 1*2*2 = 118
9: 118 - 1*1*8 = 110
After iteration 9, the function becomes idempotent:
10: 110 - 1*1*0 = 110
11: 110 - 1*1*0 = 110
12: 110 - 1*1*0 = 110
...
Additionally, 391 is the smallest number with this property. Thus, it is a(9).
MATHEMATICA
nmax = 20; tab = ConstantArray[Null, nmax];
For[k = 0, k <= 1000000, k++,
l=Length@ NestWhileList[#-Times @@ IntegerDigits[#] &, k, UnsameQ[##] &, 2]-2;
If[tab[[l+1]] == Null, tab[[l+1]] = k]]; tab (* Robert Price, Sep 13 2020 *)
PROG
(Python)
def f(x):
prod = 1
for digit in str(x):
prod *= int(digit)
return x - prod
def a(n):
i = 0
iteration = 0
while iteration != n:
i += 1
j = i
iteration = 0
new_j = f(j)
while j != new_j:
iteration += 1
j = new_j
new_j = f(j)
return i
(PARI) f(m) = m - vecprod(digits(m)) + (m==0);
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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Alon Ran, Jul 19 2020
EXTENSIONS
a(27)-a(30) from Jinyuan Wang, Aug 14 2020
a(31)-a(33) added by Michael S. Branicky, Aug 29 2020
STATUS
approved