login
A157523
Triangle T(n, k, q) = (q*(n-k) +1)*T(n-1, k-1, q) + (q*k+1)*T(n-1, k, q) + q*A157522(n, k)*T(n-2, k-1, q), with T(n, 0, q) = T(n, n, q) = 1 and q = 1, read by rows.
3
1, 1, 1, 1, 5, 1, 1, 15, 15, 1, 1, 37, 95, 37, 1, 1, 82, 463, 463, 82, 1, 1, 173, 1910, 3799, 1910, 173, 1, 1, 356, 7096, 25672, 25672, 7096, 356, 1, 1, 723, 24645, 150994, 260519, 150994, 24645, 723, 1, 1, 1458, 81499, 804875, 2259903, 2259903, 804875, 81499, 1458, 1
OFFSET
0,5
FORMULA
T(n, k, q) = (q*(n-k) +1)*T(n-1, k-1, q) + (q*k+1)*T(n-1, k, q) + q*A157522(n, k)*T(n-2, k-1, q), with T(n, 0, q) = T(n, n, q) = 1 and q = 1.
EXAMPLE
Triangle begins as:
1;
1, 1;
1, 5, 1;
1, 15, 15, 1;
1, 37, 95, 37, 1;
1, 82, 463, 463, 82, 1;
1, 173, 1910, 3799, 1910, 173, 1;
1, 356, 7096, 25672, 25672, 7096, 356, 1;
1, 723, 24645, 150994, 260519, 150994, 24645, 723, 1;
1, 1458, 81499, 804875, 2259903, 2259903, 804875, 81499, 1458, 1;
MATHEMATICA
f[n_, k_]= 1 + If[k<=Floor[n/4], k, If[Floor[n/4]<k<=Floor[n/2], Floor[n/2]-k, If[Floor[n/2]<k<=Floor[3*n/4], k-Floor[n/2], n-k]]];
A157522[n_, k_]:= f[n, k] +f[n, n-k] -1;
T[n_, k_, q_]:= T[n, k, q]= If[k==0 || k==n, 1, (q*(n-k) +1)*T[n-1, k-1, q] + (q*k+1)*T[n-1, k, q] + q*A157522[n, k]*T[n-2, k-1, q]];
Table[T[n, k, 1], {n, 0, 10}, {k, 0, n}]//Flatten (* modified by G. C. Greubel, Jan 23 2022 *)
PROG
(Sage)
def f(n, k):
if (k <= (n//4)): return k+1
elif ((n//4) < k <= (n//2)): return (n//2)-k+1
elif ((n//2) < k <= (3*n//4)): return k+1-(n//2)
else: return n-k+1
def A157522(n, k): return f(n, k) + f(n, n-k) - 1
@CachedFunction
def T(n, k, q):
if (k==0 or k==n): return 1
else: return (q*(n-k) +1)*T(n-1, k-1, q) + (q*k+1)*T(n-1, k, q) + q*A157522(n, k)*T(n-2, k-1, q);
flatten([[T(n, k, 1) for k in (0..n)] for n in (0..15)]) # G. C. Greubel, Jan 23 2022
CROSSREFS
Cf. A007318 (q=0), this sequence (q=1).
Cf. A157522.
Sequence in context: A196019 A056940 A168288 * A141691 A157147 A347973
KEYWORD
nonn,tabl
AUTHOR
Roger L. Bagula, Mar 02 2009
EXTENSIONS
Edited by G. C. Greubel, Jan 23 2022
STATUS
approved