OFFSET
1,2
COMMENTS
a(6)-a(7) from Chuck Gaydos.
MATHEMATICA
nn = 2^20; q[_] = False; q[0] = True; a[_] = 0; c[_] = -1; c[0] = 2; m = 1; {1}~Join~Reap[Do[j = c[m]; a[n] = m; c[m] = n; m = 0; If[j > 0, m = n - j]; If[! q[#2], Sow[n]; q[#2] = True] & @@ {a[n], IntegerLength[a[n]]}, {n, 3, nn}] ][[-1, -1]] (* Michael De Vlieger, Nov 05 2022 *)
PROG
(Python)
from itertools import count
def A358180(n):
b, bdict, k = 0, {0:(1, )}, 10**(n-1) if n > 1 else 0
for m in count(2):
if b >= k:
return m-1
if len(l := bdict[b]) > 1:
b = m-1-l[-2]
if b in bdict:
bdict[b] = (bdict[b][-1], m)
else:
bdict[b] = (m, )
else:
b = 0
bdict[0] = (bdict[0][-1], m) # Chai Wah Wu, Nov 05 2022
CROSSREFS
KEYWORD
nonn,hard,more
AUTHOR
G. L. Honaker, Jr., Nov 02 2022
EXTENSIONS
a(8) from Michael De Vlieger, Nov 05 2022
a(9)-a(10) from Chai Wah Wu, Nov 05 2022
a(11) from Martin Ehrenstein, Nov 05 2022
STATUS
approved