login
Irregular triangle read by rows: row n gives the word f(f(f(...(1)))) [with n applications of f], where f is the morphism 1->{1,2,1}, 2->{2,3,2}, 3->{3,1,3}.
3

%I #19 Aug 12 2017 13:03:02

%S 1,1,2,1,1,2,1,2,3,2,1,2,1,1,2,1,2,3,2,1,2,1,2,3,2,3,1,3,2,3,2,1,2,1,

%T 2,3,2,1,2,1,1,2,1,2,3,2,1,2,1,2,3,2,3,1,3,2,3,2,1,2,1,2,3,2,1,2,1,2,

%U 3,2,3,1,3,2,3,2,3,1,3,1,2,1,3,1,3,2,3,2,3,1,3,2,3,2,1,2,1,2,3,2,1,2,1,2,3

%N Irregular triangle read by rows: row n gives the word f(f(f(...(1)))) [with n applications of f], where f is the morphism 1->{1,2,1}, 2->{2,3,2}, 3->{3,1,3}.

%C Row n contains 3^n symbols.

%H Antti Karttunen, <a href="/A105202/b105202.txt">Table of n, a(n) for n = 0..9840</a>

%H F. M. Dekking, <a href="http://dx.doi.org/10.1016/0001-8708(82)90066-4">Recurrent sets</a>, Advances in Mathematics, vol. 44, no. 1 (1982), 78-104; page 96, section 4.10.

%F Let r = A062153(1+(2*n)) [index of the row], let c = n - A003462(r) [index of the column], then a(n) = 1 + (a(A003462(r-1)+floor(c/3)) mod 3) if n ≡ 2 mod 3, otherwise a(n) = a(A003462(r-1)+floor(c/3)). - _Antti Karttunen_, Aug 12 2017

%e From _Antti Karttunen_, Aug 12 2017: (Start)

%e The rows 0 .. 3 of this irregular triangle:

%e 1

%e 1;2;1

%e 1 2 1;2 3 2;1 2 1;

%e 1 2 1 2 3 2 1 2 1;2 3 2 3 1 3 2 3 2;1 2 1 2 3 2 1 2 1

%e (End)

%t f[n_] := Nest[ Flatten[ # /. {1 -> {1, 2, 1}, 2 -> {2, 3, 2}, 3 -> {3, 1, 3}}] &, {1}, n]; Flatten[ Table[ f[n], {n, 0, 4}]] (* _Robert G. Wilson v_, Apr 12 2005 *)

%o (Scheme, with memoization-macro definec)

%o (definec (A105202 n) (if (zero? n) 1 (let* ((r (A062153 (+ 1 (* 2 n)))) (c (- n (A003462 r))) (p (A105202 (+ (A003462 (- r 1)) (/ (- c (modulo c 3)) 3))))) (if (= 2 (modulo n 3)) (+ 1 (modulo p 3)) p))))

%o ;; _Antti Karttunen_, Aug 12 2017

%Y Cf. A003462, A062153, A073058, A105141.

%Y Each row is a prefix of A105203.

%K nonn,tabf

%O 0,3

%A _Roger L. Bagula_, Apr 09 2005

%E More terms from _Robert G. Wilson v_, Apr 12 2005