A350151 Variation of Van Eck's sequence A181391: a(1) = 0; a(n+1) is the positive offset from the end of the string concatenating a(1) through a(n-1) to the first appearance of a(n). a(n+1) = 0 if a(n) does not appear in the string.
0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, 2, 9, 0, 4, 9, 3, 6, 14, 0, 7, 0, 2, 12, 0, 4, 8, 0, 3, 14, 13, 0, 6, 19, 0, 4, 8, 13, 9, 6, 9, 2, 22, 53, 43, 0, 15, 0, 3, 5, 3, 2, 12, 38, 0, 9, 21, 7, 49, 57, 0, 9, 4, 6, 33, 0, 6, 4, 6, 2
Offset: 1
Examples
a(2) = 0 as a(1) = 0, which does not appear before a(1). a(15) = 6 as a(14) = 2, which first appears 6th digits back from the end of the string, '0010202216050', the decimal concatenation of a(1) through a(13). a(42) = 13 as a(41) = 14, which first appears 13 digits back from the end of the string, '001020221605026540530329049361407021204803', the decimal concatenation of a(1) through a(40).
Programs
-
Mathematica
a[1]=0;a[n_]:=a[n]=Block[{c=""<>ToString/@Most[s=Array[a,n-1]]},Check[Max[StringLength@c-Last@StringPosition[c,ToString@Last@s]]+1,0]];Array[a,81] (* Giorgos Kalogeropoulos, Dec 17 2021 *)
-
Python
a1 = '0'; print(a1, end =', '); S = a2 = '' for n in range(2, 100): p = S.rfind(a1); a = str(len(S) - p) if p != -1 else '0' print(a, end = ", "); S += a1; a2 = a1; a1 = a
Comments