OFFSET
0,3
LINKS
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
KEYWORD
nonn,tabl
AUTHOR
Reinhard Zumkeller, Apr 18 2013
STATUS
approved