|
|
A330129
|
|
a(n) is the last term of the analogous sequence to A121805, but with initial term n, or -1 if that sequence is infinite.
|
|
17
|
|
|
99999945, 9999999999999918, 36, 9999945, 999945, 9999999999999999936, 936, 9999999999972, 999999936, 999936, 999936, 99999945, 999954, 999918, 72, 99999918, 999999999927, 18, 999981, 999999999999999963, 99981, 999999999999999963, 999936, 9999999999999918, 9963
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
The numbers of terms of the corresponding sequences are in A330128.
|
|
LINKS
|
Eric Angelini, Michael S. Branicky, Giovanni Resta, N. J. A. Sloane, and David W. Wilson, The Comma Sequence: A Simple Sequence With Bizarre Properties, arXiv:2401.14346, Youtube
|
|
MATHEMATICA
|
nxt[x_] := Block[{p=1, n=x}, While[n >= 10, n = Floor[n/10]; p *= 10]; p (n + 1)]; a[n_] := Block[{nT=1, nX=n, w1, w2, w3, x, it, stp, oX}, stp = 100; w1 = w2 = w3 = 0; While[True, oX = nX; nT++; x = 10*Mod[oX, 10]; nX = SelectFirst[Range[9], IntegerDigits[oX + x + #][[1]] == # &, 0]; If[nX == 0, Break[], nX = nX + oX + x]; If[nT == stp, stp += 100; w1=w2; w2=w3; w3=nX; If[w3 + w1 == 2 w2 && Mod[w3 - w2, 100] == 0, it = Floor[(nxt[nX] - nX - 1)/(w3 - w2)]; nT += it*100; nX += (w3 - w2)*it; w3=nX; stp += it*100]]]; oX]; Array[a, 30]
|
|
PROG
|
(Python)
def nxt(x):
p, n = 1, x
while n >= 10:
n //= 10
p *= 10
return p * (n + 1)
def a(n):
nT, nX, w1, w2, w3, stp = 1, n, 0, 0, 0, 100
while True:
oX = nX
nT += 1
x = 10*(oX%10)
nX = next((y for y in range(1, 10) if str(oX+x+y)[0] == str(y)), 0)
if nX == 0: break
else: nX += oX + x
if nT == stp:
stp += 100
w1, w2, w3 = w2, w3, nX
if w3 + w1 == 2*w2 and (w3 - w2)%100 == 0:
it = (nxt(nX) - nX - 1)//(w3 - w2)
nT += it*100
nX += (w3 - w2)*it
w3 = nX
stp += it*100
return oX
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|