login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A157274
Triangle T(n, k, m) = (m*(n-k) + 1)*T(n-1, k-1, m) + (m*k + 1)*T(n-1, k, m) + m*f(n,k)*T(n-2, k-1, m) with T(n, 0, m) = T(n, n, m) = 1, f(n, k) = 2*k+1 if k <= floor(n/2) otherwise 2*(n-k)+1, and m = 3, read by rows.
23
1, 1, 1, 1, 17, 1, 1, 84, 84, 1, 1, 355, 1431, 355, 1, 1, 1442, 14827, 14827, 1442, 1, 1, 5793, 127860, 326591, 127860, 5793, 1, 1, 23200, 1009338, 5239457, 5239457, 1009338, 23200, 1, 1, 92831, 7593061, 71229038, 145043839, 71229038, 7593061, 92831, 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*f(n,k)*T(n-2, k-1, m) with T(n, 0, m) = T(n, n, m) = 1, f(n, k) = 2*k+1 if k <= floor(n/2) otherwise 2*(n-k)+1, and m = 3.
T(n, n-k, m) = T(n, k, m).
EXAMPLE
Triangle begins as:
1;
1, 1;
1, 17, 1;
1, 84, 84, 1;
1, 355, 1431, 355, 1;
1, 1442, 14827, 14827, 1442, 1;
1, 5793, 127860, 326591, 127860, 5793, 1;
1, 23200, 1009338, 5239457, 5239457, 1009338, 23200, 1;
1, 92831, 7593061, 71229038, 145043839, 71229038, 7593061, 92831, 1;
MATHEMATICA
f[n_, k_]:= If[k<=Floor[n/2], 2*k+1, 2*(n-k)+1];
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*f[n, k]*T[n-2, k-1, m]];
Table[T[n, k, 3], {n, 0, 12}, {k, 0, n}]//Flatten (* modified by G. C. Greubel, Feb 05 2022 *)
PROG
(Sage)
def f(n, k): return 2*k+1 if (k <= n//2) else 2*(n-k)+1
@CachedFunction
def T(n, k, m): # A157207
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*f(n, k)*T(n-2, k-1, m)
flatten([[T(n, k, 3) for k in (0..n)] for n in (0..12)]) # G. C. Greubel, Feb 05 2022
KEYWORD
nonn,tabl
AUTHOR
Roger L. Bagula, Feb 26 2009
EXTENSIONS
Edited by G. C. Greubel, Feb 05 2022
STATUS
approved