A133162 Trajectory of 1 under the morphism 1 -> {1,1,2,1}, 2 -> {2}.
1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1
Offset: 1
Links
Programs
-
Mathematica
Nest[Function[l, {Flatten[(l /. {1 -> {1,1,2,1}, 2 -> {2} })] }], {1}, 5] (* Georg Fischer, Jul 19 2019 *)
Formula
Denote the sequence by a(1), a(2), ...
Block t, that is, S_t, extends from n=1 through n=(3^(t+1)-1)/2.
Given n, to find a(n): first find t from
p = (3^t-1)/2 < n <= (3^(t+1)-1)/2.
Then if n=3^t, a(n) = 2. Otherwise, a(n) = a(n'), where
n' = n-p if n<3^t, otherwise n' = n-2p-1.
Comments