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.

Showing 1-4 of 4 results.

A291905 Row sums of A291904.

Original entry on oeis.org

1, 1, 0, 1, 1, 0, 2, 1, 1, 3, 2, 3, 4, 4, 6, 8, 8, 11, 14, 16, 21, 26, 32, 39, 49, 60, 75, 93, 114, 142, 176, 217, 268, 334, 411, 510, 632, 779, 967, 1196, 1477, 1832, 2266, 2801, 3470, 4291, 5310, 6572, 8129, 10061, 12449, 15401, 19058, 23581, 29178, 36102, 44668
Offset: 0

Views

Author

Seiichi Manyama, Sep 05 2017

Keywords

Comments

Number of compositions of n where the first part is 1 and the absolute difference between consecutive parts is 1.

Examples

			The a(6)=2 compositions of 6 are:
:
:  o o|
: oooo|
:
:   o|
:  oo|
: ooo|
:
The a(9)=3 compositions of 9 are:
:
:   o  |
:  ooo |
: ooooo|
:
:  o o o|
: oooooo|
:
:     o|
:  o oo|
: ooooo|
		

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; `if`(n=0, 1, add(
         `if`(j=i, 0, b(n-j, j)), j=max(1, i-1)..min(i+1, n)))
        end:
    a:= n-> b(n, 0):
    seq(a(n), n=0..60);  # Alois P. Heinz, Sep 05 2017
  • Mathematica
    T[0, 0] = 1; T[, 0] = 0; T[n?Positive, k_] /; 0 < k <= Floor[(Sqrt[8n+1] - 1)/2] := T[n, k] = T[n-k, k-1] + T[n-k, k+1]; T[, ] = 0;
    a[n_] := Sum[T[n, k], {k, 0, Floor[(Sqrt[8n+1] - 1)/2]}];
    Table[a[n], {n, 0, 60}] (* Jean-François Alcover, May 29 2019 *)
  • Python
    from sympy.core.cache import cacheit
    @cacheit
    def b(n, i): return 1 if n==0 else sum(b(n - j, j) for j in range(max(1, i - 1), min(i + 1, n) + 1) if j != i)
    def a(n): return b(n, 0)
    print([a(n) for n in range(61)]) # Indranil Ghosh, Sep 06 2017, after Maple program

A173258 Number of compositions of n where differences between neighboring parts are in {-1,1}.

Original entry on oeis.org

1, 1, 1, 3, 2, 4, 5, 5, 7, 10, 9, 14, 16, 19, 24, 31, 35, 45, 55, 66, 84, 104, 124, 156, 192, 236, 292, 363, 444, 551, 681, 839, 1040, 1287, 1586, 1967, 2430, 3001, 3717, 4597, 5683, 7034, 8697, 10758, 13312, 16469, 20369, 25204, 31180, 38574, 47726, 59047
Offset: 0

Views

Author

Alois P. Heinz, Jul 08 2012

Keywords

Examples

			a(3) = 3: [3], [2,1], [1,2].
a(4) = 2: [4], [1,2,1].
a(5) = 4: [5], [3,2], [2,3], [2,1,2].
a(6) = 5: [6], [3,2,1], [2,1,2,1], [1,2,3], [1,2,1,2].
		

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember;
          `if`(n<1 or i<1, 0, `if`(n=i, 1, add(b(n-i, i+j), j=[-1, 1])))
        end:
    a:= n-> `if`(n=0, 1, add(b(n, j), j=1..n)):
    seq(a(n), n=0..70);
  • Mathematica
    b[n_, i_] := b[n, i] = If[n < 1 || i < 1, 0, If[n == i, 1, Sum[b[n - i, i + j], {j, {-1, 1}}]]]; a[n_] := If[n == 0, 1, Sum[b[n, j], {j, 1, n}]]; Table[a[n], {n, 0, 70}] // Flatten (* Jean-François Alcover, Dec 13 2013, translated from Maple *)
  • 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])) )}
    a(n)={my(R=matid(n), t=(n==0), m=0); while(R, m++; t+=vecsum(R[n,]); R=step(R,n)); t} \\ Andrew Howroyd, Aug 23 2019

Formula

a(n) ~ c * d^n, where d=1.23729141259673487395949649334678514763130846902468..., c=1.134796087242490181499736234755111281606636700030106.... - Vaclav Kotesovec, May 01 2014
G.f.: 1 + Sum_{k>0} G(x,k) where G(x,k) = x^k*(1 + G(x,k+1) + G(x,k-1)) for k > 0 and G(x,0) = 0. - John Tyler Rascoe, Sep 16 2023

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.

A291955 Triangle read by rows: T(n,k) = T(n-k,k-1) - T(n-k,k+1) with T(0,0) = 1 for 0 <= k <= A003056(n).

Original entry on oeis.org

1, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, -1, 1, 0, 1, 0, 0, 0, 0, -1, 0, 0, 1, 1, -1, 0, -1, 0, 0, 1, 0, 0, 2, -1, 0, 0, -2, -1, 1, 0, 0, 1, 1, -1, -1, 0, -1, -3, 2, 0, 0, 3, 2, -1, -1, 1, 0, -2, -3, 2, 1, 0, 0, 3, 4, -3, -1, 0, 0, -4, -4, 3, 2, -1, 0, 4
Offset: 0

Views

Author

Seiichi Manyama, Sep 06 2017

Keywords

Examples

			First few rows are:
  1;
  0,  1;
  0,  0;
  0,  0,  1;
  0, -1,  0;
  0,  0,  0;
  0,  0, -1,  1;
  0,  1,  0,  0;
  0,  0, -1,  0;
  0,  1,  1, -1;
  0, -1,  0,  0, 1.
		

Crossrefs

Row sums give A291956.
Columns 0-1 give A000007, A049346.
Cf. A291904.
Showing 1-4 of 4 results.