login
A157148
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.
23
1, 1, 1, 1, 8, 1, 1, 33, 33, 1, 1, 112, 394, 112, 1, 1, 353, 3150, 3150, 353, 1, 1, 1080, 20719, 51192, 20719, 1080, 1, 1, 3265, 122535, 620415, 620415, 122535, 3265, 1, 1, 9824, 681040, 6312360, 12805614, 6312360, 681040, 9824, 1, 1, 29505, 3643980, 57451300, 209503086, 209503086, 57451300, 3643980, 29505, 1
OFFSET
0,5
FORMULA
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.
T(n, n-k, 2) = T(n, k, 2).
EXAMPLE
Triangle begins as:
1;
1, 1;
1, 8, 1;
1, 33, 33, 1;
1, 112, 394, 112, 1;
1, 353, 3150, 3150, 353, 1;
1, 1080, 20719, 51192, 20719, 1080, 1;
1, 3265, 122535, 620415, 620415, 122535, 3265, 1;
1, 9824, 681040, 6312360, 12805614, 6312360, 681040, 9824, 1;
1, 29505, 3643980, 57451300, 209503086, 209503086, 57451300, 3643980, 29505, 1;
MAPLE
A157148 := proc(n, k)
option remember;
if k < 0 or k> n then 0;
elif k = 0 or k = n then 1;
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);
end if;
end proc:
seq(seq(A157148(n, k), k=0..n), n=0..10) ; # R. J. Mathar, Feb 06 2015
MATHEMATICA
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]];
Table[T[n, k, 2], {n, 0, 10}, {k, 0, n}]//Flatten (* modified by G. C. Greubel, Jan 09 2022 *)
PROG
(Sage)
@CachedFunction
def T(n, k, m): # A157148
if (k==0 or k==n): return 1
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)
flatten([[T(n, k, 2) for k in (0..n)] for n in (0..20)]) # G. C. Greubel, Jan 09 2022
CROSSREFS
Cf. A007318 (m=0), A157147 (m=1), this sequence (m=2), A157149 (m=3), A157150 (m=4), A157151 (m=5).
Sequence in context: A178347 A141686 A185412 * A220595 A154335 A142467
KEYWORD
nonn,tabl,easy
AUTHOR
Roger L. Bagula, Feb 24 2009
EXTENSIONS
Edited by G. C. Greubel, Jan 09 2022
STATUS
approved