%I #40 May 31 2019 05:11:40
%S 1,1,1,1,2,1,1,5,7,3,1,8,22,24,9,1,11,46,90,81,27,1,14,79,228,351,270,
%T 81,1,17,121,465,1035,1323,891,243,1,20,172,828,2430,4428,4860,2916,
%U 729,1,23,232,1344,4914,11718,18144,17496,9477,2187,1,26,301,2040,8946,26460,53298,71928,61965,30618,6561
%N Triangle T(n,k) read by rows, arising in enumeration of catafusenes.
%H G. C. Greubel, <a href="/A024462/b024462.txt">Rows n = 0..20 of triangle, flattened</a>
%H S. J. Cyvin, B. N. Cyvin, and J. Brunvoll, <a href="https://hrcak.srce.hr/177109">Unbranched catacondensed polygonal systems containing hexagons and tetragons</a>, Croatica Chem. Acta, 69 (1996), 757-774; see Table III (p. 767).
%F T(n, k) = 3 * T(n-1, k-1) + T(n-1, k), starting with [1], [1, 1], [1, 2, 1].
%F From _Petros Hadjicostas_, May 27 2019: (Start)
%F T(n, k) = (n-2)!/(k! * (n-k)!) * (9*n*(n-1) - 4*k*(3*n-k-2)) * 3^(k-2) for n >= max(k, 2) and k >= 0. (See the top formula of p. 767 in Cyvin et al. (1996).)
%F Bivariate g.f.: Sum_{n, k >= 0} T(n, k) * x^n * y^k = 1 + x * (1 + y) + x^2 * (1 + y)^2/(1 - x - 3 * x * y).
%F (End)
%e Triangle begins (rows indexed by n >= 0 and columns by k >= 0):
%e 1;
%e 1, 1;
%e 1, 2, 1;
%e 1, 5, 7, 3;
%e 1, 8, 22, 24, 9;
%e 1, 11, 46, 90, 81, 27;
%e 1, 14, 79, 228, 351, 270, 81;
%e 1, 17, 121, 465, 1035, 1323, 891, 243;
%e 1, 20, 172, 828, 2430, 4428, 4860, 2916, 729;
%e ...
%p ## The following Maple program gives the Taylor expansion of the bivariate g.f. of T(n,k) in powers of x:
%p T := proc (x, y) 1+x*(y+1)+x^2*(y+1)^2/(1-x-3*y*x) end proc;
%p expand(taylor(T(x, y), x = 0, 20)); ## _Petros Hadjicostas_, May 27 2019
%t T[n_, 0]:= 1; T[n_, k_]:= If[k<0 || k>n, 0, If[n==1 && k==1, 1, If[n==2 && k==1, 2, If[k==n && n>=2, 3^(n-2), 3*T[n-1, k-1] + T[n-1, k]]]]];
%t Table[T[n, k], {n, 0, 10}, {k, 0, n}]//Flatten (* _G. C. Greubel_, May 30 2019 *)
%o (PARI) T(n,k)=if(n<0||k<0||k>n,0,if(n<3,[[1],[1,1],[1,2,1]][n+1][k+1],3*T(n-1,k-1)+T(n-1,k))) \\ _Ralf Stephan_, Jan 25 2005
%o (Sage)
%o def T(n, k):
%o if (k<0 and k>n): return 0
%o elif (k==0): return 1
%o elif (n==k==1): return 1
%o elif (n==2 and k==1): return 2
%o elif (n>=2 and k==n): return 3^(n-2)
%o else: return 3*T(n-1, k-1) + T(n-1, k)
%o [[T(n, k) for k in (0..n)] for n in (0..12)] # _G. C. Greubel_, May 30 2019
%Y Cf. A038763.
%Y Left-edge columns (essentially) include A016789 and A038764. Right-edge diagonal columns (essentially) include A000244, A038765, and A081892. Row sums are (essentially) A000302.
%K tabl,nonn,easy
%O 0,5
%A _N. J. A. Sloane_, May 03 2000
%E More terms from _James A. Sellers_, May 03 2000
%E Edited by _Ralf Stephan_, Jan 25 2005