login
Triangle, read by rows, where T(n,k) = n*T(n-1,k-1) + T(n-1,k-2) for n>0 and k>1, with T(n,0) = T(n-1,n-1) and T(n,1) = n*T(n-1,0) for n>0 and T(0,0) = 1.
2

%I #10 Dec 15 2017 13:44:13

%S 1,1,1,1,2,3,3,3,7,11,11,12,15,31,51,51,55,71,87,170,286,286,306,381,

%T 481,593,1107,1886,1886,2002,2428,2973,3748,4632,8342,14309,14309,

%U 15088,17902,21426,26212,32957,40804,71368,122814,122814,128781,150101,176206

%N Triangle, read by rows, where T(n,k) = n*T(n-1,k-1) + T(n-1,k-2) for n>0 and k>1, with T(n,0) = T(n-1,n-1) and T(n,1) = n*T(n-1,0) for n>0 and T(0,0) = 1.

%C Row sums yield factorials (A000142).

%H G. C. Greubel, <a href="/A132005/b132005.txt">Table of n, a(n) for the first 50 rows, flattened</a>

%e Triangle begins:

%e 1;

%e 1, 1;

%e 1, 2, 3;

%e 3, 3, 7, 11;

%e 11, 12, 15, 31, 51;

%e 51, 55, 71, 87, 170, 286;

%e 286, 306, 381, 481, 593, 1107, 1886;

%e 1886, 2002, 2428, 2973, 3748, 4632, 8342, 14309;

%e 14309, 15088, 17902, 21426, 26212, 32957, 40804, 71368, 122814;

%e 122814, 128781, 150101, 176206, 210736, 257334, 322825, 400193, 683116, 1176694;

%e ...

%t T[n_, k_] := T[n, k] = If[k < 0 || n < k, 0, If[n == 0 && k == 0, 1, If[k == 0, T[n - 1, n - 1], n*T[n - 1, k - 1] + T[n - 1, k - 2]]]]; Table[ T[n, k], {n, 0, 10}, {k, 0, n}] (* _G. C. Greubel_, Dec 15 2017 *)

%o (PARI) T(n,k)=if(k<0 || n<k,0,if(n==0 && k==0,1,if(k==0,T(n-1,n-1),n*T(n-1,k-1)+T(n-1,k-2))))

%Y Cf. A132006 (column 0).

%K nonn,tabl

%O 0,5

%A _Paul D. Hanna_, Aug 07 2007