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-10 of 24 results. Next

A325557 Number of compositions of n with equal differences up to sign.

Original entry on oeis.org

1, 1, 2, 4, 6, 8, 13, 12, 20, 24, 25, 29, 49, 40, 50, 64, 86, 80, 105, 102, 164, 175, 186, 208, 325, 316, 382, 476, 624, 660, 814, 961, 1331, 1500, 1739, 2140, 2877, 3274, 3939, 4901, 6345, 7448, 9054, 11157, 14315, 17181, 20769, 25843, 32947, 39639, 48257, 60075
Offset: 0

Views

Author

Gus Wiseman, May 11 2019

Keywords

Comments

A composition of n is a finite sequence of positive integers summing to n.
The differences of a sequence are defined as if the sequence were increasing, so for example the differences of (3,1,2) are (-2,1).

Examples

			The a(1) = 1 through a(8) = 20 compositions:
  (1)  (2)   (3)    (4)     (5)      (6)       (7)        (8)
       (11)  (12)   (13)    (14)     (15)      (16)       (17)
             (21)   (22)    (23)     (24)      (25)       (26)
             (111)  (31)    (32)     (33)      (34)       (35)
                    (121)   (41)     (42)      (43)       (44)
                    (1111)  (131)    (51)      (52)       (53)
                            (212)    (123)     (61)       (62)
                            (11111)  (141)     (151)      (71)
                                     (222)     (232)      (161)
                                     (321)     (313)      (242)
                                     (1212)    (12121)    (323)
                                     (2121)    (1111111)  (1232)
                                     (111111)             (1313)
                                                          (2123)
                                                          (2222)
                                                          (2321)
                                                          (3131)
                                                          (3212)
                                                          (21212)
                                                          (11111111)
		

Crossrefs

Programs

  • Mathematica
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],SameQ@@Abs[Differences[#]]&]],{n,0,15}]
  • PARI
    step(R,n,s)={matrix(n, n, i, j, if(i>j, if(j>s, R[i-j, j-s]) + if(j+s<=n, R[i-j, j+s])) )}
    w(n,s)={my(R=matid(n), t=0); while(R, R=step(R,n,s); t+=vecsum(R[n,])); t}
    a(n) = {numdiv(max(1,n)) + sum(s=1, n-1, w(n,s))} \\ Andrew Howroyd, Aug 22 2019

Extensions

a(26)-a(42) from Lars Blomberg, May 30 2019
Terms a(43) and beyond from Andrew Howroyd, Aug 22 2019

A214247 Number A(n,k) of compositions of n where differences between neighboring parts are in {-k,k}; square array A(n,k), n>=0, k>=0, read by antidiagonals.

Original entry on oeis.org

1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 3, 3, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 3, 4, 4, 1, 1, 1, 1, 1, 2, 5, 2, 1, 1, 1, 1, 1, 3, 3, 5, 4, 1, 1, 1, 1, 1, 1, 2, 2, 7, 3, 1, 1, 1, 1, 1, 1, 3, 3, 6, 10, 4, 1, 1, 1, 1, 1, 1, 1, 2, 1, 4, 9, 2
Offset: 0

Views

Author

Alois P. Heinz, Jul 08 2012

Keywords

Examples

			A(5,0) = 2: [5], [1,1,1,1,1].
A(5,1) = 4: [5], [3,2], [2,3], [2,1,2].
A(5,2) = 2: [5], [1,3,1].
A(5,3) = 3: [5], [4,1], [1,4].
Square array A(n,k) begins:
  1,  1,  1,  1,  1,  1,  1,  1,  1, ...
  1,  1,  1,  1,  1,  1,  1,  1,  1, ...
  2,  1,  1,  1,  1,  1,  1,  1,  1, ...
  2,  3,  1,  1,  1,  1,  1,  1,  1, ...
  3,  2,  3,  1,  1,  1,  1,  1,  1, ...
  2,  4,  2,  3,  1,  1,  1,  1,  1, ...
  4,  5,  3,  2,  3,  1,  1,  1,  1, ...
  2,  5,  2,  3,  2,  3,  1,  1,  1, ...
  4,  7,  6,  1,  3,  2,  3,  1,  1, ...
		

Crossrefs

Columns k=0-2 give: A000005, A173258, A214254.
Rows n=0, 1 and main diagonal give: A000012.

Programs

  • Maple
    b:= proc(n, i, k) option remember;
          `if`(n<1 or i<1, 0, `if`(n=i, 1, add(b(n-i, i+j, k), j={-k, k})))
        end:
    A:= (n, k)-> `if`(n=0, 1, add(b(n, j, k), j=1..n)):
    seq(seq(A(n, d-n), n=0..d), d=0..15);
  • Mathematica
    b[n_, i_, k_] := b[n, i, k] = If[n < 1 || i < 1, 0, If[n == i, 1, Sum[b[n - i, i + j, k], { j, Union[{-k, k}]}]]]; a[n_, k_] := If[n == 0, 1, Sum[b[n, j, k], {j, 1, n}]]; Table[Table[a[n, d - n], {n, 0, d}], {d, 0, 15}] // Flatten (* Jean-François Alcover, Dec 13 2013, translated from Maple *)
  • PARI
    tri(k) = {(k*(k+1)/2)}
    ra(n) = {(sqrt(1+8*n)-1)/2}
    C(q,n) = {c = if(n<=1, return(1)); return(sum(i=0, n-1, C(q, i) * C(q, n-1-i) * q^((i+1)*(n-1 -i))));}
    Cw_q(i,k) = {return(q^(((k+2)*i)+1) * polrecip(C(q^(2*k),i)))}
    A_qt(k,N) = {1 + sum(i=0,N/(k+1), t^((2*i)+1) * Cw_q(i,k) * (sum(j=0,ra(N+2)+1, prod(u=1,j, sum(v=0,(N-(tri(u)*k))/(k+2), t^((2*v)+1) * q^(((2*v)+1)*u*k) * Cw_q(v,k)))))^2)}
    A_q(k,N) = {my(q='q+O('q^N), Aqt = A_qt(k,N), Aq = 1); for(i=1,poldegree(Aqt,t), Aq += polcoef(Aqt,i,t)/(1-q^i)); Aq}
    A214247_array(maxrow,maxcolumn) = {my(m=concat([1],vector(maxrow,n,numdiv(n)))~); for(k=1,maxcolumn, m = matconcat([m,Vec(A_q(k,maxrow))~])); m}
    A214247_array(10,10) \\ John Tyler Rascoe, Oct 15 2024

Formula

G.f. for column k > 0: A(k,q) is A(k,q,t) = Sum_{n,m>=0} (q^n)*(t^m) under the transform (q^n)*(t^m) -> (q^n)/(1-q^m) for all m > 0 where A(k,q,t) = 1 + Sum_{i>=0} ( t^((2*i)+1) * Cw(i,k,q) * (Sum_{j>=0} (Product_{u=1..j} (Sum_{v>=0} t^((2*v)+1) * q^(((2*v)+1)*k*u) * Cw(v,k,q))))^2 ), Cw(i,k,q) = q^(((k+2)*i)+1) * Ca(i,q^(2*k)), and Ca(i,q) is the i-th Carlitz-Riordan q-Catalan number (i-th row polynomial of A227543). - John Tyler Rascoe, Sep 13 2024

A227310 G.f.: 1/G(0) where G(k) = 1 + (-q)^(k+1) / (1 - (-q)^(k+1)/G(k+1) ).

Original entry on oeis.org

1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 2, 1, 1, 3, 2, 3, 4, 4, 6, 7, 8, 11, 13, 16, 20, 24, 31, 37, 46, 58, 70, 88, 108, 133, 167, 204, 252, 315, 386, 479, 594, 731, 909, 1122, 1386, 1720, 2124, 2628, 3254, 4022, 4980, 6160, 7618, 9432, 11665, 14433, 17860, 22093, 27341, 33824, 41847, 51785, 64065, 79267
Offset: 0

Views

Author

Joerg Arndt, Jul 06 2013

Keywords

Comments

Number of rough sandpiles: 1-dimensional sandpiles (see A186085) with n grains without flat steps (no two successive parts of the corresponding composition equal), see example. - Joerg Arndt, Mar 08 2014
The sequence of such sandpiles by base length starts (n>=0) 1, 1, 0, 1, 0, 2, 0, 5, 0, 14, 0, 42, 0, ... (A097331, essentially A000108 with interlaced zeros). This is a consequence of the obvious connection to Dyck paths, see example. - Joerg Arndt, Mar 09 2014
a(n>=1) are the Dyck paths with area n between the x-axis and the path which return to the x-axis only once (at their end), whereas A143951 includes paths with intercalated touches of the x-axis. - R. J. Mathar, Aug 22 2018

Examples

			From _Joerg Arndt_, Mar 08 2014: (Start)
The a(21) = 7 rough sandpiles are:
:
:   1:      [ 1 2 1 2 1 2 1 2 1 2 3 2 1 ]  (composition)
:
:           o
:  o o o o ooo
: ooooooooooooo  (rendering of sandpile)
:
:
:   2:      [ 1 2 1 2 1 2 1 2 3 2 1 2 1 ]
:
:         o
:  o o o ooo o
: ooooooooooooo
:
:
:   3:      [ 1 2 1 2 1 2 3 2 1 2 1 2 1 ]
:
:       o
:  o o ooo o o
: ooooooooooooo
:
:
:   4:      [ 1 2 1 2 3 2 1 2 1 2 1 2 1 ]
:
:     o
:  o ooo o o o
: ooooooooooooo
:
:
:   5:      [ 1 2 3 2 1 2 1 2 1 2 1 2 1 ]
:
:   o
:  ooo o o o o
: ooooooooooooo
:
:
:   6:      [ 1 2 3 2 3 4 3 2 1 ]
:
:      o
:   o ooo
:  ooooooo
: ooooooooo
:
:
:   7:      [ 1 2 3 4 3 2 3 2 1 ]
:
:    o
:   ooo o
:  ooooooo
: ooooooooo
(End)
From _Joerg Arndt_, Mar 09 2014: (Start)
The A097331(9) = 14 such sandpiles with base length 9 are:
01:  [ 1 2 1 2 1 2 1 2 1 ]
02:  [ 1 2 1 2 1 2 3 2 1 ]
03:  [ 1 2 1 2 3 2 3 2 1 ]
04:  [ 1 2 1 2 3 2 1 2 1 ]
05:  [ 1 2 1 2 3 4 3 2 1 ]
06:  [ 1 2 3 2 1 2 3 2 1 ]
07:  [ 1 2 3 2 1 2 1 2 1 ]
08:  [ 1 2 3 2 3 2 1 2 1 ]
09:  [ 1 2 3 2 3 2 3 2 1 ]
10:  [ 1 2 3 4 3 2 1 2 1 ]
11:  [ 1 2 3 2 3 4 3 2 1 ]
12:  [ 1 2 3 4 3 2 3 2 1 ]
13:  [ 1 2 3 4 3 4 3 2 1 ]
14:  [ 1 2 3 4 5 4 3 2 1 ]
(End)
		

Crossrefs

Cf. A049346 (g.f.: 1 - 1/G(0), where G(k)= 1 + q^(k+1) / (1 - q^(k+1)/G(k+1) ) ).
Cf. A226728 (g.f.: 1/G(0), where G(k) = 1 + q^(k+1) / (1 - q^(k+1)/G(k+2) ) ).
Cf. A226729 (g.f.: 1/G(0), where G(k) = 1 - q^(k+1) / (1 - q^(k+1)/G(k+2) ) ).
Cf. A006958 (g.f.: 1/G(0), where G(k) = 1 - q^(k+1) / (1 - q^(k+1)/G(k+1) ) ).
Cf. A227309 (g.f.: 1/G(0), where G(k) = 1 - q^(k+1) / (1 - q^(k+2)/G(k+1) ) ).

Programs

  • PARI
    N = 66;  q = 'q + O('q^N);
    G(k) = if(k>N, 1, 1 + (-q)^(k+1) / (1 - (-q)^(k+1) / G(k+1) ) );
    gf = 1 / G(0);
    Vec(gf)
    
  • PARI
    N = 66;  q = 'q + O('q^N);
    F(q,y,k) = if(k>N, 1, 1/(1 - y*q^2 * F(q, q^2*y, k+1) ) );
    Vec( 1 + q * F(q,q,0) ) \\ Joerg Arndt, Mar 09 2014

Formula

a(0) = 1 and a(n) = abs(A049346(n)) for n>=1.
G.f.: 1/ (1-q/(1+q/ (1+q^2/(1-q^2/ (1-q^3/(1+q^3/ (1+q^4/(1-q^4/ (1-q^5/(1+q^5/ (1+-...) )) )) )) )) )).
G.f.: 1 + q * F(q,q) where F(q,y) = 1/(1 - y * q^2 * F(q, q^2*y) ); cf. A005169 and p. 841 of the Odlyzko/Wilf reference; 1/(1 - q * F(q,q)) is the g.f. of A143951. - Joerg Arndt, Mar 09 2014
G.f.: 1 + q/(1 - q^3/(1 - q^5/(1 - q^7/ (...)))) (from formulas above). - Joerg Arndt, Mar 09 2014
G.f.: F(x, x^2) where F(x,y) is the g.f. of A239927. - Joerg Arndt, Mar 29 2014
a(n) ~ c * d^n, where d = 1.23729141259673487395949649334678514763130846902468... and c = 0.0773368373684184197215007198148835507944051447907... - Vaclav Kotesovec, Sep 05 2017
G.f.: A(x) = 2 -1/A143951(x). - R. J. Mathar, Aug 23 2018

A325546 Number of compositions of n with weakly increasing differences.

Original entry on oeis.org

1, 1, 2, 4, 7, 11, 19, 28, 41, 62, 87, 120, 170, 228, 303, 408, 534, 689, 899, 1145, 1449, 1842, 2306, 2863, 3571, 4398, 5386, 6610, 8039, 9716, 11775, 14157, 16938, 20293, 24166, 28643, 33995, 40134, 47199, 55540, 65088, 75994, 88776, 103328, 119886, 139126
Offset: 0

Views

Author

Gus Wiseman, May 10 2019

Keywords

Comments

Also compositions of n whose plot is concave-up.
A composition of n is a finite sequence of positive integers summing to n.
The differences of a sequence are defined as if the sequence were increasing, so for example the differences of (3,1,2) are (-2,1).

Examples

			The a(1) = 1 through a(6) = 19 compositions:
  (1)  (2)   (3)    (4)     (5)      (6)
       (11)  (12)   (13)    (14)     (15)
             (21)   (22)    (23)     (24)
             (111)  (31)    (32)     (33)
                    (112)   (41)     (42)
                    (211)   (113)    (51)
                    (1111)  (212)    (114)
                            (311)    (123)
                            (1112)   (213)
                            (2111)   (222)
                            (11111)  (312)
                                     (321)
                                     (411)
                                     (1113)
                                     (2112)
                                     (3111)
                                     (11112)
                                     (21111)
                                     (111111)
		

Crossrefs

Programs

  • Mathematica
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],LessEqual@@Differences[#]&]],{n,0,15}]
  • PARI
    \\ Row sums of R(n) give A007294 (=breakdown by width).
    R(n)={my(L=List(), v=vectorv(n, i, 1), w=1, t=1); while(v, listput(L,v); w++; t+=w; v=vectorv(n, i, sum(k=1, (i-w-1)\t + 1, v[i-w-(k-1)*t]))); Mat(L)}
    seq(n)={my(M=R(n)); Vec(1 + sum(i=1, n, my(p=sum(w=1, min(#M,n\i), x^(w*i)*sum(j=1, n-i*w, x^j*M[j,w])));  x^i/(1 - x^i)*(1 + p + O(x*x^(n-i)))^2))} \\ Andrew Howroyd, Aug 28 2019

Extensions

More terms from Alois P. Heinz, May 11 2019

A214249 Number A(n,k) of compositions of n where differences between neighboring parts are in {-k,...,k} \ {0}; square array A(n,k), n>=0, k>=0, read by antidiagonals.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 3, 4, 4, 1, 1, 1, 1, 3, 4, 5, 5, 1, 1, 1, 1, 3, 4, 7, 11, 5, 1, 1, 1, 1, 3, 4, 7, 12, 14, 7, 1, 1, 1, 1, 3, 4, 7, 14, 20, 18, 10, 1, 1, 1, 1, 3, 4, 7, 14, 21, 30, 36, 9, 1, 1, 1, 1, 3, 4, 7, 14, 23, 36, 50, 49, 14, 1
Offset: 0

Views

Author

Alois P. Heinz, Jul 08 2012

Keywords

Examples

			A(3,0) = 1: [3].
A(4,1) = 2: [4], [1,2,1].
A(5,2) = 5: [5], [3,2], [2,3], [2,1,2], [1,3,1].
A(6,3) = 12: [6], [4,2], [3,2,1], [3,1,2], [2,4], [2,3,1], [2,1,3], [2,1,2,1], [1,4,1], [1,3,2], [1,2,3], [1,2,1,2].
Square array A(n,k) begins:
  1,  1,  1,  1,  1,  1,  1,  1, ...
  1,  1,  1,  1,  1,  1,  1,  1, ...
  1,  1,  1,  1,  1,  1,  1,  1, ...
  1,  3,  3,  3,  3,  3,  3,  3, ...
  1,  2,  4,  4,  4,  4,  4,  4, ...
  1,  4,  5,  7,  7,  7,  7,  7, ...
  1,  5, 11, 12, 14, 14, 14, 14, ...
  1,  5, 14, 20, 21, 23, 23, 23, ...
		

Crossrefs

Columns k=0-2 give: A000012, A173258, A214256.
Main diagonal gives: A003242.

Programs

  • Maple
    b:= proc(n, i, k) option remember; `if`(n<1 or i<1, 0,
          `if`(n=i, 1, add(b(n-i, i+j, k), j={$-k..k} minus{0})))
        end:
    A:= (n, k)-> `if`(n=0, 1, add(b(n, j, min(n, k)), j=1..n)):
    seq(seq(A(n, d-n), n=0..d), d=0..15);
  • Mathematica
    b[n_, i_, k_] := b[n, i, k] = If[n<1 || i<1, 0, If[n == i, 1, Sum[b[n-i, i+j, k], {j, Range[-k, -1] ~Join~ Range[k]}]]]; A[n_, k_] := If[n == 0, 1, Sum[b[n, j, Min[n, k]], {j, 1, n}]]; Table[Table[A[n, d-n], {n, 0, d}], {d, 0, 15}] // Flatten (* Jean-François Alcover, Jan 15 2014, translated from Maple *)

A325558 Number of compositions of n with equal circular differences up to sign.

Original entry on oeis.org

1, 2, 4, 5, 6, 10, 8, 16, 13, 16, 18, 32, 20, 30, 30, 57, 34, 52, 46, 96, 74, 86, 84, 174, 119, 170, 192, 306, 244, 332, 372, 628, 560, 694, 812, 1259, 1228, 1566, 1852, 2696, 2806, 3538, 4260, 5894, 6482, 8098, 9890, 13392, 15049, 18706, 23018, 30298, 35198
Offset: 1

Views

Author

Gus Wiseman, May 11 2019

Keywords

Comments

A composition of n is a finite sequence of positive integers summing to n.
The circular differences of a composition c of length k are c_{i + 1} - c_i for i < k and c_1 - c_i for i = k. For example, the circular differences of (1,2,1,3) are (1,-1,2,-2).

Examples

			The a(1) = 1 through a(8) = 16 compositions:
  (1)  (2)   (3)    (4)     (5)      (6)       (7)        (8)
       (11)  (12)   (13)    (14)     (15)      (16)       (17)
             (21)   (22)    (23)     (24)      (25)       (26)
             (111)  (31)    (32)     (33)      (34)       (35)
                    (1111)  (41)     (42)      (43)       (44)
                            (11111)  (51)      (52)       (53)
                                     (222)     (61)       (62)
                                     (1212)    (1111111)  (71)
                                     (2121)               (1232)
                                     (111111)             (1313)
                                                          (2123)
                                                          (2222)
                                                          (2321)
                                                          (3131)
                                                          (3212)
                                                          (11111111)
		

Crossrefs

Programs

  • Mathematica
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],SameQ@@Abs[Differences[Append[#,First[#]]]]&]],{n,15}]
  • PARI
    step(R,n,s)={matrix(n, n, i, j, if(i>j, if(j>s, R[i-j, j-s]) + if(j+s<=n, R[i-j, j+s])) )}
    w(n,k,s)={my(R=matrix(n,n,i,j,i==j&&abs(i-k)==s), t=0); while(R, R=step(R,n,s); t+=R[n,k]); t}
    a(n) = {numdiv(max(1,n)) + sum(s=1, n-1, sum(k=1, n, w(n,k,s)))} \\ Andrew Howroyd, Aug 22 2019

Extensions

a(26)-a(42) from Lars Blomberg, May 30 2019
Terms a(43) and beyond from Andrew Howroyd, Aug 22 2019

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.

Original entry on oeis.org

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

Views

Author

Andrew Howroyd, Aug 23 2019

Keywords

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.

Examples

			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)
		

Crossrefs

Row sums are A173258.
T(2n,n) gives A364529.

Programs

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

A363718 Irregular triangle read by rows. An infinite binary tree which has root node 1 in row n = 0. Each node then has left child m-1 if greater than 0 and right child m+1, where m is the value of the parent node.

Original entry on oeis.org

1, 2, 1, 3, 2, 2, 4, 1, 3, 1, 3, 3, 5, 2, 2, 4, 2, 2, 4, 2, 4, 4, 6, 1, 3, 1, 3, 3, 5, 1, 3, 1, 3, 3, 5, 1, 3, 3, 5, 3, 5, 5, 7, 2, 2, 4, 2, 2, 4, 2, 4, 4, 6, 2, 2, 4, 2, 2, 4, 2, 4, 4, 6, 2, 2, 4, 2, 4, 4, 6, 2, 4, 4, 6, 4, 6, 6, 8, 1, 3, 1, 3, 3, 5, 1, 3, 1
Offset: 0

Views

Author

John Tyler Rascoe, Jun 17 2023

Keywords

Comments

The paths through the tree represent the compositions counted in A173258 that have first part 1.
For rows n > 1, row n starts with row n-2.
Any positive number k will first appear in the (k-1)-th row and thereafter in rows of opposite parity to k. The number of times k will appear in row n is A053121(n,k-1).
Row n >= 1 gives the row lengths of the Christmas tree pattern of order n (cf. A367508). - Paolo Xausa, Nov 26 2023
A new row can be generated by applying the morphism 1 -> 2, t -> {t-1,t+1} (for t > 1) to the previous row. - Paolo Xausa, Dec 08 2023

Examples

			Triangle begins:
  n=0:  1;
  n=1:  2;
  n=2:  1, 3;
  n=3:  2, 2, 4;
  n=4:  1, 3, 1, 3, 3, 5;
  n=5:  2, 2, 4, 2, 2, 4, 2, 4, 4, 6;
  n=6:  1, 3, 1, 3, 3, 5, 1, 3, 1, 3, 3, 5, 1, 3, 3, 5, 3, 5, 5, 7;
  ...
The binary tree starts with root 1 in row n = 0. In row n = 2, the parent node 2 has the first left child since 2 - 1 > 0.
The tree begins:
row
[n]
[0]                   1
                       \
[1]            _________2_________
              /                   \
[2]          1                _____3_____
              \              /           \
[3]          __2__        __2__         __4__
            /     \      /     \       /     \
[4]        1       3    1       3     3       5
            \     / \    \     / \   / \     / \
[5]          2   2   4    2   2   4 2   4   4   6
.
		

Crossrefs

Cf. A001405 (row lengths), A000079 (row sums).

Programs

  • Mathematica
    SubstitutionSystem[{1->{2},t_/;t>1:>{t-1,t+1}},{1},8] (* Paolo Xausa, Dec 23 2023 *)
  • Python
    def A363718_rowlist(root,row):
        A = [[root]]
        for i in range(0,row):
            A.append([])
            for j in range(0,len(A[i])):
                if A[i][j] != 1:
                    A[i+1].append(A[i][j]-1)
                A[i+1].append(A[i][j]+1)
        return(A)
    A363718_rowlist(1, 8)

A325553 Number of compositions of n with distinct circular differences up to sign.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 7, 21, 31, 41, 87, 99, 191, 245, 381, 501, 735, 883, 1309, 1841, 2589, 3435, 4941, 6857, 9791, 13503, 19475, 27073, 37175, 52299, 72249, 100359, 139317, 190549, 256769, 355193, 471963, 644433, 858793, 1159161, 1530879, 2056073, 2711921
Offset: 0

Views

Author

Gus Wiseman, May 11 2019

Keywords

Comments

A composition of n is a finite sequence of positive integers summing to n.
The circular differences of a composition c of length k are c_{i + 1} - c_i for i < k and c_1 - c_i for i = k. For example, the circular differences of (1,2,1,3) are (1,-1,2,-2).

Examples

			The a(1) = 1 through a(8) = 21 compositions:
  (1)  (2)  (3)  (4)  (5)  (6)  (7)    (8)
                                (124)  (125)
                                (142)  (134)
                                (214)  (143)
                                (241)  (152)
                                (412)  (215)
                                (421)  (251)
                                       (314)
                                       (341)
                                       (413)
                                       (431)
                                       (512)
                                       (521)
                                       (1124)
                                       (1142)
                                       (1241)
                                       (1421)
                                       (2114)
                                       (2411)
                                       (4112)
                                       (4211)
		

Crossrefs

Programs

  • Mathematica
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],UnsameQ@@Abs[Differences[Append[#,First[#]]]]&]],{n,20}]

Extensions

a(0) and a(26)-a(43) from Alois P. Heinz, Jan 28 2024

A325589 Number of compositions of n whose circular differences are all 1 or -1.

Original entry on oeis.org

0, 0, 2, 0, 2, 2, 2, 4, 4, 2, 8, 6, 8, 10, 12, 16, 18, 20, 28, 34, 42, 48, 62, 78, 92, 112, 146, 174, 216, 264, 326, 412, 500, 614, 770, 944, 1166, 1444, 1784, 2214, 2730, 3366, 4182, 5164, 6386, 7898, 9770, 12098, 14950, 18488, 22894, 28312, 35020, 43330, 53606
Offset: 1

Views

Author

Gus Wiseman, May 11 2019

Keywords

Comments

A composition of n is a finite sequence of positive integers summing to n.
The circular differences of a composition c of length k are c_{i + 1} - c_i for i < k and c_1 - c_i for i = k. For example, the circular differences of (1,2,1,3) are (1,-1,2,-2).

Examples

			The a(3) = 2 through a(11) = 8 compositions (empty columns not shown):
  (12)  (23)  (1212)  (34)  (1232)  (45)      (2323)  (56)
  (21)  (32)  (2121)  (43)  (2123)  (54)      (3232)  (65)
                            (2321)  (121212)          (121232)
                            (3212)  (212121)          (123212)
                                                      (212123)
                                                      (212321)
                                                      (232121)
                                                      (321212)
		

Crossrefs

Programs

  • Mathematica
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],SameQ[1,##]&@@Abs[Differences[Append[#,First[#]]]]&]],{n,15}]
  • PARI
    step(R,n,s)={matrix(n, n, i, j, if(i>j, if(j>s, R[i-j, j-s]) + if(j+s<=n, R[i-j, j+s])) )}
    a(n)={sum(k=1, n, my(R=matrix(n,n,i,j,i==j&&abs(i-k)==1), t=0); while(R, R=step(R,n,1); t+=R[n,k]); t)} \\ Andrew Howroyd, Aug 23 2019

Extensions

Terms a(26) and beyond from Andrew Howroyd, Aug 23 2019
Showing 1-10 of 24 results. Next