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

A309938
Triangle read by rows: T(n,k) is the number of compositions of n with k parts and differences all equal to 1 or -1.
8
1, 1, 0, 1, 2, 0, 1, 0, 1, 0, 1, 2, 1, 0, 0, 1, 0, 2, 2, 0, 0, 1, 2, 1, 0, 1, 0, 0, 1, 0, 1, 4, 1, 0, 0, 0, 1, 2, 2, 0, 3, 2, 0, 0, 0, 1, 0, 1, 4, 2, 0, 1, 0, 0, 0, 1, 2, 1, 0, 3, 6, 1, 0, 0, 0, 0, 1, 0, 2, 4, 3, 0, 4, 2, 0, 0, 0, 0, 1, 2, 1, 0, 3, 8, 3, 0, 1, 0, 0, 0, 0
OFFSET
1,5
COMMENTS
Parts will alternate between being odd and even. For even k, a composition cannot be the same as its reversal and therefore for even k, T(n,k) is even.
LINKS
EXAMPLE
Triangle begins:
1;
1, 0;
1, 2, 0;
1, 0, 1, 0;
1, 2, 1, 0, 0;
1, 0, 2, 2, 0, 0;
1, 2, 1, 0, 1, 0, 0;
1, 0, 1, 4, 1, 0, 0, 0;
1, 2, 2, 0, 3, 2, 0, 0, 0;
1, 0, 1, 4, 2, 0, 1, 0, 0, 0;
1, 2, 1, 0, 3, 6, 1, 0, 0, 0, 0;
1, 0, 2, 4, 3, 0, 4, 2, 0, 0, 0, 0;
1, 2, 1, 0, 3, 8, 3, 0, 1, 0, 0, 0, 0;
1, 0, 1, 4, 3, 0, 6, 8, 1, 0, 0, 0, 0, 0;
1, 2, 2, 0, 4, 10, 5, 0, 5, 2, 0, 0, 0, 0, 0;
...
For n = 6 there are a total of 5 compositions:
k = 1: (6)
k = 3: (123), (321)
k = 4: (2121), (1212)
MAPLE
b:= proc(n, i) option remember; `if`(n<1 or i<1, 0,
`if`(n=i, x, add(expand(x*b(n-i, i+j)), j=[-1, 1])))
end:
T:= n-> (p-> seq(coeff(p, x, i), i=1..n))(add(b(n, j), j=1..n)):
seq(T(n), n=1..14); # Alois P. Heinz, Jul 22 2023
MATHEMATICA
b[n_, i_] := b[n, i] = If[n < 1 || i < 1, 0, If[n == i, x, Sum[Expand[x*b[n - i, i + j]], {j, {-1, 1}}]]];
T[n_] := CoefficientList[Sum[b[n, j], {j, 1, n}], x] // Rest // PadRight[#, n]&;
Table[T[n], {n, 1, 13}] // Flatten (* Jean-François Alcover, Sep 06 2023, after Alois P. Heinz *)
PROG
(PARI)
step(R, n)={matrix(n, n, i, j, if(i>j, if(j>1, R[i-j, j-1]) + if(j+1<=n, R[i-j, j+1])) )}
T(n)={my(v=vector(n), R=matid(n), m=0); while(R, m++; v[m]+=vecsum(R[n, ]); R=step(R, n)); v}
for(n=1, 15, print(T(n)))
CROSSREFS
Row sums are A173258.
T(2n,n) gives A364529.
Sequence in context: A116927 A137276 A287234 * A140581 A137277 A039975
KEYWORD
nonn,tabl
AUTHOR
Andrew Howroyd, Aug 23 2019
STATUS
approved