login
A224791
Triangle T(n,k) read by rows: left edge is 0, 1, 2, ... (cf. A001477); otherwise each entry is sum of entry to left and entries immediately above it to left and right, with 1 for the missing right term at right edge.
2
0, 1, 2, 2, 5, 8, 3, 10, 23, 32, 4, 17, 50, 105, 138, 5, 26, 93, 248, 491, 630, 6, 37, 156, 497, 1236, 2357, 2988, 7, 50, 243, 896, 2629, 6222, 11567, 14556, 8, 65, 358, 1497, 5022, 13873, 31662, 57785, 72342, 9, 82, 505, 2360, 8879, 27774, 73309, 162756
OFFSET
0,3
FORMULA
T(n,0) = n, T(n+1,k) = T(n+1,k-1) + T(n,k-1) + T(n,k) (0 < k <= n) and T(n+1,n+1) = T(n+1,n) + T(n,n) + 1.
EXAMPLE
Triangle begins:
0;
1, 2;
2, 5, 8;
3, 10, 23, 32;
4, 17, 50, 105, 138;
MAPLE
T:= proc(n, k) option remember;
if k=0 then n
elif k=n then T(n, n-1) + T(n-1, n-1) + 1
else T(n, k-1) + T(n-1, k-1) + T(n-1, k)
fi
end:
seq(seq(T(n, k), k=0..n), n=0..12); # G. C. Greubel, Nov 12 2019
MATHEMATICA
T[n_, k_]:= T[n, k]= If[k==0, n, If[k==n , T[n, n-1] + T[n-1, n-1] + 1, T[n, k-1] + T[n-1, k-1] + T[n-1, k]]]; Table[T[n, k], {n, 0, 12}, {k, 0, n}]//Flatten (* G. C. Greubel, Nov 12 2019 *)
PROG
(Haskell)
a224791 n k = a224791_tabl !! n !! k
a224791_row n = a224791_tabl !! n
a224791_tabl = iterate
(\row -> scanl1 (+) $ zipWith (+) ([1] ++ row) (row ++ [1])) [0]
(PARI) T(n, k) = if(k==0, n, if(k==n, T(n, n-1) + T(n-1, n-1) + 1, T(n, k-1) + T(n-1, k-1) + T(n-1, k) )); \\ G. C. Greubel, Nov 12 2019
(Sage)
@CachedFunction
def T(n, k):
if (k==0): return n
elif (k==n): return T(n, n-1) + T(n-1, n-1) + 1
else: return T(n, k-1) + T(n-1, k-1) + T(n-1, k)
[[T(n, k) for k in (0..n)] for n in (0..12)] # G. C. Greubel, Nov 12 2019
CROSSREFS
Sequence in context: A077232 A193891 A193906 * A210637 A201972 A202396
KEYWORD
nonn,tabl
AUTHOR
Reinhard Zumkeller, Apr 18 2013
STATUS
approved