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”).

A026703
Triangular array T read by rows: T(n,1) = T(n,n) = 1, T(n,k) = T(n-1, k-1) + T(n-2,k-1) + T(n-1,k) if k=(n/2) or k=((n+1)/2), otherwise T(n,k) = T(n-1,k-1) + T(n-1,k).
16
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, 1, 10, 48, 155, 293, 155, 48, 10, 1, 1, 11, 58, 203, 564, 564, 203, 58, 11, 1, 1, 12, 69, 261, 767, 1421, 767, 261, 69, 12, 1
OFFSET
1,5
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
Sequence in context: A275421 A243576 A211314 * A122917 A211315 A096583
KEYWORD
nonn,tabl
STATUS
approved