OFFSET
1,5
LINKS
G. C. Greubel, Rows n = 1..100 of triangle, flattened
FORMULA
T(n, k) = number of paths from (0, 0) to (n-k, k) in the directed graph having vertices (i, j) and edges (i, j)-to-(i+1, j) and (i, j)-to-(i, j+1) for i, j >= 0 and edges (i, j)-to-(i+1, j+1) if |i-j|<=1.
EXAMPLE
Triangle begins:
1,
1, 1,
1, 3, 1,
1, 5, 5, 1,
1, 6, 13, 6, 1,
1, 7, 24, 24, 7, 1,
1, 8, 31, 61, 31, 8, 1,
1, 9, 39, 116, 116, 39, 9, 1,
...
MATHEMATICA
T[n_, k_]:= T[n, k]= If[k==1 || k==n, 1, If[k==n/2 || k==(n+1)/2 || k== (n+2)/2, T[n-1, k-1] +T[n-2, k-1] +T[n-1, k], T[n-1, k-1] +T[n-1, k]]];
Table[T[n, k], {n, 12}, {k, n}]//Flatten (* G. C. Greubel, Jul 17 2019 *)
PROG
(PARI) T(n, k) = if(k==1 || k==n, 1, if(k==n/2 || k==(n+1)/2 || k==(n+2)/2 , T(n-1, k-1) + T(n-2, k-1) + T(n-1, k), T(n-1, k-1) + T(n-1, k) ));
for(n=1, 12, for(k=1, n, print1(T(n, k), ", "))) \\ G. C. Greubel, Jul 17 2019
(Sage)
def T(n, k):
if (k==1 or k==n): return 1
elif (k==n/2 or k==(n+1)/2 or k==(n+2)/2): return T(n-1, k-1) + T(n-2, k-1) + T(n-1, k)
else: return T(n-1, k-1) + T(n-1, k)
[[T(n, k) for k in (1..n)] for n in (1..12)] # G. C. Greubel, Jul 17 2019
(GAP)
T:= function(n, k)
if (k=1 or k=n) then return 1;
elif (k=Int(n/2) and k=Int((n+1)/2) or k=Int((n+2)/2)) then return T(n-1, k-1) + T(n-2, k-1) + T(n-1, k);
else return T(n-1, k-1) + T(n-1, k);
fi;
end;
Flat(List([1..12], n-> List([1..n], k-> T(n, k) ))); # G. C. Greubel, Jul 17 2019
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
STATUS
approved