login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 7

%I #22 Sep 06 2023 13:24:47

%S 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,

%T 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,

%U 2,4,3,0,4,2,0,0,0,0,1,2,1,0,3,8,3,0,1,0,0,0,0

%N 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.

%C 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.

%H Alois P. Heinz, <a href="/A309938/b309938.txt">Rows n = 1..200, flattened</a>

%e Triangle begins:

%e 1;

%e 1, 0;

%e 1, 2, 0;

%e 1, 0, 1, 0;

%e 1, 2, 1, 0, 0;

%e 1, 0, 2, 2, 0, 0;

%e 1, 2, 1, 0, 1, 0, 0;

%e 1, 0, 1, 4, 1, 0, 0, 0;

%e 1, 2, 2, 0, 3, 2, 0, 0, 0;

%e 1, 0, 1, 4, 2, 0, 1, 0, 0, 0;

%e 1, 2, 1, 0, 3, 6, 1, 0, 0, 0, 0;

%e 1, 0, 2, 4, 3, 0, 4, 2, 0, 0, 0, 0;

%e 1, 2, 1, 0, 3, 8, 3, 0, 1, 0, 0, 0, 0;

%e 1, 0, 1, 4, 3, 0, 6, 8, 1, 0, 0, 0, 0, 0;

%e 1, 2, 2, 0, 4, 10, 5, 0, 5, 2, 0, 0, 0, 0, 0;

%e ...

%e For n = 6 there are a total of 5 compositions:

%e k = 1: (6)

%e k = 3: (123), (321)

%e k = 4: (2121), (1212)

%p b:= proc(n, i) option remember; `if`(n<1 or i<1, 0,

%p `if`(n=i, x, add(expand(x*b(n-i, i+j)), j=[-1, 1])))

%p end:

%p T:= n-> (p-> seq(coeff(p, x, i), i=1..n))(add(b(n, j), j=1..n)):

%p seq(T(n), n=1..14); # _Alois P. Heinz_, Jul 22 2023

%t 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 T[n_] := CoefficientList[Sum[b[n, j], {j, 1, n}], x] // Rest // PadRight[#, n]&;

%t Table[T[n], {n, 1, 13}] // Flatten (* _Jean-François Alcover_, Sep 06 2023, after _Alois P. Heinz_ *)

%o (PARI)

%o 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])) )}

%o T(n)={my(v=vector(n), R=matid(n), m=0); while(R, m++; v[m]+=vecsum(R[n,]); R=step(R,n)); v}

%o for(n=1, 15, print(T(n)))

%Y Row sums are A173258.

%Y T(2n,n) gives A364529.

%Y Cf. A309931, A309937, A309939, A325557.

%K nonn,tabl

%O 1,5

%A _Andrew Howroyd_, Aug 23 2019

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 12:27 EDT 2024. Contains 371912 sequences. (Running on oeis4.)