login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A055794
Triangle T read by rows: T(i,0)=1 for i >= 0; T(i,i)=1 for i=0,1,2,3; T(i,i)=0 for i >= 4; T(i,j) = T(i-1,j) + T(i-2,j-1) for 1<=j<=i-1.
6
1, 1, 1, 1, 2, 1, 1, 3, 2, 1, 1, 4, 4, 2, 0, 1, 5, 7, 4, 1, 0, 1, 6, 11, 8, 3, 0, 0, 1, 7, 16, 15, 7, 1, 0, 0, 1, 8, 22, 26, 15, 4, 0, 0, 0, 1, 9, 29, 42, 30, 11, 1, 0, 0, 0, 1, 10, 37, 64, 56, 26, 5, 0, 0, 0, 0, 1, 11, 46, 93, 98, 56, 16, 1, 0, 0, 0, 0, 1, 12, 56, 130, 162, 112, 42, 6, 0, 0, 0, 0, 0
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
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
Row sums: A000204 (Lucas numbers).
Cf. subsequences T(2n+m,n): A000125 (m=0, cake numbers), A055795 (m=1), A027660 (m=2), A055796 (m=3), A055797 (m=4), A055798 (m=5), A055799 (m=6).
Sequence in context: A077592 A343658 A194005 * A092905 A052509 A172119
KEYWORD
nonn,tabl
AUTHOR
Clark Kimberling, May 28 2000
EXTENSIONS
Typo in definition corrected by Georg Fischer, Dec 03 2021
STATUS
approved