login
A364039
Triangle read by rows: T(n,k) is the number of integer compositions of n with first part k and differences between neighboring parts in {-1,1}.
3
1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 2, 1, 0, 1, 0, 2, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 3, 2, 0, 0, 0, 0, 1, 0, 3, 2, 1, 2, 1, 0, 0, 0, 1, 0, 2, 3, 2, 1, 0, 0, 0, 0, 0, 1, 0, 3, 4, 3, 1, 1, 1, 0, 0, 0, 0, 1, 0, 4, 4, 4, 2, 1, 0, 0, 0, 0, 0, 0, 1
OFFSET
0,18
LINKS
FORMULA
T(n,n) = 1.
T(n,k) = T(n-k,k+1) + T(n-k,k-1) for 0 < k < n.
T(n,k) = 0 for n < k.
T(n,0) = 0 for 0 < n.
EXAMPLE
Triangle begins:
1;
0, 1;
0, 0, 1;
0, 1, 1, 1;
0, 1, 0, 0, 1;
0, 0, 2, 1, 0, 1;
0, 2, 1, 1, 0, 0, 1;
0, 1, 1, 1, 1, 0, 0, 1;
0, 1, 3, 2, 0, 0, 0, 0, 1;
0, 3, 2, 1, 2, 1, 0, 0, 0, 1;
0, 2, 3, 2, 1, 0, 0, 0, 0, 0, 1;
...
For n = 6 there are a total of 5 compositions:
T(6,1) = 2: (123), (1212)
T(6,2) = 1: (2121)
T(6,3) = 1: (321)
T(6,6) = 1: (6)
MAPLE
T:= proc(n, i) option remember; `if`(n<1 or i<1, 0,
`if`(n=i, 1, add(T(n-i, i+j), j=[-1, 1])))
end: T(0$2):=1:
seq(seq(T(n, k), k=0..n), n=0..14); # Alois P. Heinz, Aug 08 2023
PROG
(Python)
def A364039_rowlist(row_max):
A = []
for n in range(0, row_max+1):
A.append([])
for k in range(0, n+1):
z = 0
if n==k: z += 1
elif k > 1 and k-1 <= n-k: z += A[n-k][k-1]
if k+1 <= n-k and k != 0: z += A[n-k][k+1]
A[n].append(z)
print(A[n])
A364039_rowlist(12)
CROSSREFS
Cf. A291905 (column k=1), A173258 (row sums).
Sequence in context: A339895 A068906 A162514 * A376362 A166347 A055300
KEYWORD
nonn,easy,tabl
AUTHOR
John Tyler Rascoe, Aug 06 2023
STATUS
approved