OFFSET
0,5
COMMENTS
T(i+j,j) is the number of strings (s(1),...,s(i+1)) of nonnegative integers s(k) such that 0<=s(k)-s(k-1)<=1 for k=2,3,...,i+1 and s(i+1)=j.
T(i+j,j) is the number of compositions of j consisting of i parts, all of in {0,1}.
LINKS
G. C. Greubel, Rows n = 0..100 of triangle, flattened
Clark Kimberling, Path-counting and Fibonacci numbers, Fib. Quart. 40 (4) (2002) 328-338, Example 1B.
EXAMPLE
Triangle begins:
1;
1, 1;
1, 2, 1;
1, 3, 2, 1;
1, 4, 4, 2, 0;
1, 5, 7, 4, 1, 0;
...
T(7,4) counts the strings 3334, 3344, 3444, 2234, 2334, 2344, 1234.
T(7,4) counts the compositions 001, 010, 100, 011, 101, 110, 111.
MAPLE
T:= proc(n, k) option remember;
if k=0 then 1
elif k=n and n<4 then 1
elif k=n then 0
else T(n-1, k) + T(n-2, k-1)
fi; end:
seq(seq(T(n, k), k=0..n), n=0..12); # G. C. Greubel, Jan 25 2020
MATHEMATICA
T[n_, k_]:= T[n, k]= If[k==0, 1, If[k==n && n<4, 1, If[k==n, 0, T[n-1, k] + T[n-2, k-1] ]]]; Table[T[n, k], {n, 0, 12}, {k, 0, n}]//Flatten (* G. C. Greubel, Jan 25 2020 *)
PROG
(PARI) T(n, k) = if(k==0, 1, if(k==n && n<4, 1, if(k==n, 0, T(n-1, k) + T(n-2, k-1) )));
for(n=0, 12, for(k=0, n, print1(T(n, k), ", "))) \\ G. C. Greubel, Jan 25 2020
(Magma)
function T(n, k)
if k eq 0 then return 1;
elif k eq n and n lt 4 then return 1;
elif k eq n then return 0;
else return T(n-1, k) + T(n-2, k-1);
end if; return T; end function;
[T(n, k): k in [0..n], n in [0..12]]; // G. C. Greubel, Jan 25 2020
(Sage)
@CachedFunction
def T(n, k):
if (k==0): return 1
elif (k==n and n<4): return 1
elif (k==n): return 0
else: return T(n-1, k) + T(n-2, k-1)
[[T(n, k) for k in (0..n)] for n in (0..12)] # G. C. Greubel, Jan 25 2020
(GAP)
T:= function(n, k)
if k=0 then return 1;
elif k=n and n<4 then return 1;
elif k=n then return 0;
else return T(n-1, k) + T(n-2, k-1);
fi; end;
Flat(List([0..12], n-> List([0..n], k-> T(n, k) ))); # G. C. Greubel, Jan 25 2020
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Clark Kimberling, May 28 2000
EXTENSIONS
Typo in definition corrected by Georg Fischer, Dec 03 2021
STATUS
approved