OFFSET
0,8
COMMENTS
LINKS
G. C. Greubel, Rows n = 0..50 of triangle, flattened
FORMULA
A001590(k+1) = T(n,k) if 0 <= k <= n. - Michael Somos, Jun 01 2014
EXAMPLE
Triangle T(n,k) for 0 <= k <= 2n:
1;
1, 0, 1;
1, 0, 1, 2, 1;
1, 0, 1, 2, 3, 4, 1;
1, 0, 1, 2, 3, 6, 9, 8, 1;
MAPLE
T:= proc(n, k) option remember;
if k=0 or k=2 or k=2*n then 1
elif k=1 then 0
else add(T(n-1, k-j), j=1..3)
fi
end:
seq(seq(T(n, k), k=0..2*n), n=0..10); # G. C. Greubel, Nov 05 2019
MATHEMATICA
T[n_, k_]:= T[n, k]= If[k==0 || k==2 || k==2*n, 1, If[k==1, 0, Sum[T[n-1, k-j], {j, 3}]]]; Table[T[n, k], {n, 0, 12}, {k, 0, 2*n}]//Flatten (* G. C. Greubel, Nov 05 2019 *)
PROG
(PARI) {T(n, k) = if(k==0 || k==2 || k==2*n, 1, if(k==1, 0, sum(j=1, 3, T(n-1, k-j)) ))};
for(n=0, 10, for(k=0, 2*n, print1(T(n, k), ", "))) \\ G. C. Greubel, Nov 05 2019
(Sage)
@CachedFunction
def T(n, k):
if (k==0 or k==2 or k==2*n): return 1
elif (k==1): return 0
else: return sum(T(n-1, k-j) for j in (1..3))
[[T(n, k) for k in (0..2*n)] for n in (0..10)] # G. C. Greubel, Nov 05 2019
(GAP)
T:= function(n, k)
if k=0 or k=2 or k=2*n then return 1;
elif k=1 then return 0;
else return Sum([1..3], j-> T(n-1, k-j) );
fi;
end;
Flat(List([0..10], n-> List([0..2*n], k-> T(n, k) ))); # G. C. Greubel, Nov 05 2019
CROSSREFS
Cf. A001590, a tribonacci sequence.
Diagonals T(n, 2n-c): A027056 (c=1), A027058 (c=2), A027059 (c=3), A027060 (c=4), A027061(c=5), A027062 (c=6), A027063 (c=7), A027064 (c=8), A027065 (c=9), A027066 (c=10).
KEYWORD
nonn,tabf
AUTHOR
EXTENSIONS
Offset and keyword:tabl corrected by R. J. Mathar, Jun 01 2009
STATUS
approved