cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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}.

Original entry on oeis.org

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

Views

Author

John Tyler Rascoe, Aug 06 2023

Keywords

Examples

			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)
		

Crossrefs

Cf. A291905 (column k=1), A173258 (row sums).

Programs

  • 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
  • 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)

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.