login
T(n, k) = 3*T(n-1, k-1) + T(n-1, k) for k < n and T(n, n) = 1, T(n, k) = 0, if k < 0 or k > n; triangle read by rows.
2

%I #19 Aug 29 2022 10:34:05

%S 1,1,1,1,4,1,1,7,13,1,1,10,34,40,1,1,13,64,142,121,1,1,16,103,334,547,

%T 364,1,1,19,151,643,1549,2005,1093,1,1,22,208,1096,3478,6652,7108,

%U 3280,1,1,25,274,1720,6766,17086,27064,24604,9841,1,1,28,349,2542,11926,37384,78322,105796,83653,29524,1

%N T(n, k) = 3*T(n-1, k-1) + T(n-1, k) for k < n and T(n, n) = 1, T(n, k) = 0, if k < 0 or k > n; triangle read by rows.

%H G. C. Greubel, <a href="/A119673/b119673.txt">Rows n = 0..100 of triangle, flattened</a>

%F T(n,k) = R(n,k,3) where R(n,k,m) = (1-m)^(-n+k)-m^(k+1)*Pochhammer(n-k, k+1)* hyper2F1([1,n+1],[k+2],m)/(k+1)!. - _Peter Luschny_, Jul 25 2014

%e Triangle begins:

%e 1;

%e 1, 1;

%e 1, 4, 1;

%e 1, 7, 13, 1;

%e 1, 10, 34, 40, 1;

%e 1, 13, 64, 142, 121, 1;

%e 1, 16, 103, 334, 547, 364, 1;

%e 1, 19, 151, 643, 1549, 2005, 1093, 1;

%e 1, 22, 208, 1096, 3478, 6652, 7108, 3280, 1;

%e 1, 25, 274, 1720, 6766, 17086, 27064, 24604, 9841, 1;

%p T := (n,k,m) -> (1-m)^(-n+k)-m^(k+1)*pochhammer(n-k,k+1)* hypergeom([1,n+1],[k+2],m)/(k+1)!; A119673 := (n,k) -> T(n,k,3);

%p seq(print(seq(round(evalf(A119673(n,k))),k=0..n)),n=0..10); # _Peter Luschny_, Jul 25 2014

%t T[_, 0]=1; T[n_, n_]=1; T[n_, k_]/; 0<k<n := T[n, k] = 3T[n-1, k-1] + T[n-1, k]; T[_, _] = 0;

%t Table[T[n, k], {n, 0, 10}, {k, 0, n}] (* _Jean-François Alcover_, Jun 13 2019 *)

%o (PARI) T(n,k) = if(k<0 || k>n, 0, if(k==n, 1, 3*T(n-1, k-1) +T(n-1,k)));

%o for(n=0,12, for(k=0,n, print1(T(n,k), ", "))) \\ _G. C. Greubel_, Nov 18 2019

%o (Magma)

%o function T(n,k)

%o if k lt 0 or k gt n then return 0;

%o elif k eq n then return 1;

%o else return 3*T(n-1,k-1) + T(n-1,k);

%o end if;

%o return T;

%o end function;

%o [T(n,k): k in [0..n], n in [0..12]]; // _G. C. Greubel_, Nov 18 2019

%o (Sage)

%o @CachedFunction

%o def T(n, k):

%o if (k<0 or k>n): return 0

%o elif (k==n): return 1

%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_, Nov 18 2019

%Y Cf. A003462, A014915, A081271, A119258.

%K easy,nonn,tabl

%O 0,5

%A _Zerinvary Lajos_, Jun 11 2006

%E Definition clarified by _Philippe Deléham_, Jun 13 2006

%E Entry revised by _N. J. A. Sloane_, Jun 19 2006