login
A358168
First n-digit number to occur in Van Eck's Sequence (A181391).
4
0, 14, 131, 1024, 10381, 100881, 1014748, 10001558, 100246289, 1000943528, 10010107437
OFFSET
1,2
COMMENTS
a(6)-a(7) from Chuck Gaydos.
EXAMPLE
a(2) = 14 because 14 is the first 2-digit number occurring in A181391.
MATHEMATICA
nn = 2^20; q[_] = False; q[0] = True; a[_] = 0; c[_] = -1; c[0] = 2; m = 1; {0}~Join~Rest@ Reap[Do[j = c[m]; a[n] = m; c[m] = n; m = 0; If[j > 0, m = n - j]; If[! q[#2], Sow[#1]; 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 A358168(n):
b, bdict, k = 0, {0:(1, )}, 10**(n-1) if n > 1 else 0
for m in count(2):
if b >= k:
return b
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
Sequence in context: A208427 A006565 A206207 * A026936 A021114 A328785
KEYWORD
nonn,base,hard,more
AUTHOR
G. L. Honaker, Jr., Nov 01 2022
EXTENSIONS
a(8)-a(10) from Chai Wah Wu, Nov 05 2022
a(11) from Martin Ehrenstein, Nov 05 2022
STATUS
approved