%I #11 Aug 22 2014 10:12:35
%S 1,4,7,16,25,31,43,61,70,88,97,115,220,286,322,475,557,1072,1334,1598,
%T 1751,1964,1991,2385,2494,2909,2936,3326,3935,4518,5363,5696,6232,
%U 6323,6541,6940,7120,7570,7840,12217,12397,12906,13901,16129,18277,20342,20803
%N Index sequence for limit-reversing A000002; see Comments.
%C Suppose S = (s(0),s(1),s(2),...) is an infinite sequence such that every finite block of consecutive terms occurs infinitely many times in S. (It is assumed that A006337 is such a sequence.) Let B = B(m,k) = (s(m-k),s(m-k+1),...,s(m)) be such a block, where m >= 0 and k >= 0. Let m(1) be the least i > m such that (s(i-k),s(i-k+1),...,s(i)) = B(m,k), and put B(m(1),k+1) = (s(m(1)-k-1),s(m(1)-k),...,s(m(1))). Let m(2) be the least i > m(1) such that (s(i-k-1),s(i-k),...,s(i)) = B(m(1),k+1), and put B(m(2),k+2) = (s(m(2)-k-2),s(m(2)-k-1),...,s(m(2))). Continuing in this manner gives a sequence of blocks B(m(n),k+n). Let B'(n) = reverse(B(m(n),k+n)), so that for n >= 1, B'(n) comes from B'(n-1) by suffixing a single term; thus the limit of B'(n) is defined; we call it the "limit-reverse of S with initial block B(m,k)", denoted by S*(m,k), or simply S*. (Since A000002 has offset 1, the above definition is adapted accordingly, so that s(n) = A000002(n+1) for n >= 0.)
%C ...
%C The sequence (m(i)), where m(0) = 1, is the "index sequence for limit-reversing S with initial block B(m,k)" or simply the index sequence for S*, as in A245937.
%e S = A000002 (re-indexed to start with s(0) = 1, with B = (s(0)); that is, (m,k) = (0,0); S = (1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1,2,1,1,,...)
%e B'(0) = (1)
%e B'(1) = (1,2)
%e B'(2) = (1,2,1)
%e B'(3) = (1,2,1,1)
%e B'(4) = (1,2,1,1,2)
%e B'(5) = (1,2,1,1,2,2)
%e S* = (1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1,...),
%e with index sequence (1, 4, 7, 16, 25, 31, 43, 61, 70, 88, 97, 115,...)
%t z = 50; seqPosition2[list_, seqtofind_] := Last[Last[Position[Partition[list, Length[#], 1], Flatten[{___, #, ___}], 1, 2]]] &[seqtofind]; n = 30; s = Prepend[Nest[ Flatten[Partition[#, 2] /. {{2, 2} -> {2, 2, 1, 1}, {2, 1} -> {2, 2, 1}, {1, 2} -> {2, 1, 1}, {1, 1} -> {2, 1}}] &, {2, 2}, n], 1]; ans = Join[{s[[p[0] = pos = seqPosition2[s, #] - 1]]}, #] &[{s[[1]]}]; cfs = Table[s = Drop[s, pos - 1]; ans = Join[{s[[p[n] = pos = seqPosition2[s, #] - 1]]}, #] &[ans], {n, z}]; q = Accumulate[Join[{1}, Table[p[n], {n, 0, z}]]] (* A245937 *)
%Y Cf. A000002, A245936, A245920.
%K nonn
%O 1,2
%A _Clark Kimberling_ and _Peter J. C. Moses_, Aug 07 2014