%I #12 Jan 10 2022 03:07:10
%S 1,1,1,1,8,1,1,33,33,1,1,112,394,112,1,1,353,3150,3150,353,1,1,1080,
%T 20719,51192,20719,1080,1,1,3265,122535,620415,620415,122535,3265,1,1,
%U 9824,681040,6312360,12805614,6312360,681040,9824,1,1,29505,3643980,57451300,209503086,209503086,57451300,3643980,29505,1
%N Triangle T(n, k, m) = (m*(n-k) + 1)*T(n-1, k-1, m) + (m*k + 1)*T(n-1, k, m) + m*k*(n-k)*T(n-2, k-1, m) with T(n, 0, m) = T(n, n, m) = 1 and m = 2, read by rows.
%H G. C. Greubel, <a href="/A157148/b157148.txt">Rows n = 0..50 of the triangle, flattened</a>
%F T(n, k, m) = (m*(n-k) + 1)*T(n-1, k-1, m) + (m*k + 1)*T(n-1, k, m) + m*k*(n-k)*T(n-2, k-1, m) with T(n, 0, m) = T(n, n, m) = 1 and m = 2.
%F T(n, n-k, 2) = T(n, k, 2).
%e Triangle begins as:
%e 1;
%e 1, 1;
%e 1, 8, 1;
%e 1, 33, 33, 1;
%e 1, 112, 394, 112, 1;
%e 1, 353, 3150, 3150, 353, 1;
%e 1, 1080, 20719, 51192, 20719, 1080, 1;
%e 1, 3265, 122535, 620415, 620415, 122535, 3265, 1;
%e 1, 9824, 681040, 6312360, 12805614, 6312360, 681040, 9824, 1;
%e 1, 29505, 3643980, 57451300, 209503086, 209503086, 57451300, 3643980, 29505, 1;
%p A157148 := proc(n,k)
%p option remember;
%p if k < 0 or k> n then 0;
%p elif k = 0 or k = n then 1;
%p else (2*(n-k)+1)*procname(n-1,k-1) + (2*k+1)*procname(n-1,k) + 2*k*(n-k)*procname(n-2,k-1);
%p end if;
%p end proc:
%p seq(seq(A157148(n,k),k=0..n),n=0..10) ; # _R. J. Mathar_, Feb 06 2015
%t T[n_, k_, m_]:= T[n, k, m]= If[k==0 || k==n, 1, (m*(n-k)+1)*T[n-1,k-1,m] + (m*k+1)*T[n-1,k,m] + m*k*(n-k)*T[n-2,k-1,m]];
%t Table[T[n,k,2], {n,0,10}, {k,0,n}]//Flatten (* modified by _G. C. Greubel_, Jan 09 2022 *)
%o (Sage)
%o @CachedFunction
%o def T(n,k,m): # A157148
%o if (k==0 or k==n): return 1
%o else: return (m*(n-k) +1)*T(n-1,k-1,m) + (m*k+1)*T(n-1,k,m) + m*k*(n-k)*T(n-2,k-1,m)
%o flatten([[T(n,k,2) for k in (0..n)] for n in (0..20)]) # _G. C. Greubel_, Jan 09 2022
%Y Cf. A007318 (m=0), A157147 (m=1), this sequence (m=2), A157149 (m=3), A157150 (m=4), A157151 (m=5).
%Y Cf. A157152, A157153, A157154, A157155, A157156, A157207, A157208, A157209, A157210, A157211, A157212, A157268, A157272, A157273, A157274, A157275.
%K nonn,tabl,easy
%O 0,5
%A _Roger L. Bagula_, Feb 24 2009
%E Edited by _G. C. Greubel_, Jan 09 2022