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 15 results. Next

A085197 Positions of ones in A007001. Repeating part in each sub-permutation A082315[A014137(n-1)..A014138(n-1)] normalized to begin from 1.

Original entry on oeis.org

1, 3, 6, 8, 11, 15, 17, 20, 22, 25, 29, 31, 34, 38, 43, 45, 48, 50, 53, 57, 59, 62, 64, 67, 71, 73, 76, 80, 85, 87, 90, 92, 95, 99, 101, 104, 108, 113, 115, 118, 122, 127, 133, 135, 138, 140, 143, 147, 149, 152, 154, 157, 161, 163, 166, 170, 175, 177, 180, 182, 185, 189
Offset: 1

Views

Author

Antti Karttunen, Jun 14 2003. Proposed by Wouter Meeussen Mar 15 2003

Keywords

Comments

From the second term 3 onward also one more than the partial sums of A076050.

Crossrefs

Cf. A085196. First column of A085180.

Programs

  • Mathematica
    PositionIndex[Nest[Flatten[Map[Range[#+1] &, #]] &, {1}, 6]][[1]] (* Paolo Xausa, Mar 04 2024 *)

Formula

a(n) = A080336(n-1) + n = A082854(A082315(A072795(A081291(n-1)))).
a(n) = n if n < 2, otherwise a(n-1)+A076050(n-1).

A085180 Array A(x,y) giving the position of the y-th x in A007001 listed by rising antidiagonals.

Original entry on oeis.org

1, 2, 3, 5, 4, 6, 14, 10, 7, 8, 42, 28, 13, 9, 11, 132, 84, 37, 19, 12, 15, 429, 264, 112, 41, 24, 16, 17, 1430, 858, 354, 126, 56, 27, 18, 20, 4862, 2860, 1155, 402, 131, 70, 33, 21, 22, 16796, 9724, 3861, 1320, 422, 174, 79, 36, 23, 25, 58786, 33592, 13156, 4433
Offset: 1

Views

Author

Antti Karttunen, Jun 18 2003

Keywords

Comments

Read by upwards antidiagonals as A(1,1), A(2,1), A(1,2), A(3,1), A(2,2), A(1,3), etc.

Examples

			In A007001 each n occurs for the first time at position Cat(n), thus A(x,1) (the first row) is A000108.
		

Crossrefs

Variant: A085178.
Inverse permutation: A085181.
First row: A000108, second row: A068875 apart from initial terms, first column: A085197, central diagonal: A001453.

A080336 Partial sums of A007001.

Original entry on oeis.org

0, 1, 3, 4, 6, 9, 10, 12, 13, 15, 18, 19, 21, 24, 28, 29, 31, 32, 34, 37, 38, 40, 41, 43, 46, 47, 49, 52, 56, 57, 59, 60, 62, 65, 66, 68, 71, 75, 76, 78, 81, 85, 90, 91, 93, 94, 96, 99, 100, 102, 103, 105, 108, 109, 111, 114, 118, 119, 121
Offset: 0

Views

Author

Benoit Cloitre, Mar 18 2003

Keywords

Crossrefs

The repeating subsequences in A085196 increase to this sequence. Difference between the position of (n+1)-th 1 in A007001 (= A085197(n)) and A007001(n+1). Also a(n) = A085196(A081291(n)).

A085182 n occurs A076050(n) (= A007001(n)+1) times.

Original entry on oeis.org

1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 18, 19, 19, 19, 19, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, 25, 26, 26, 26, 27, 27
Offset: 1

Views

Author

Antti Karttunen, Jun 18 2003

Keywords

Crossrefs

Can be used to compute A085193.

A133912 First differences of A007001.

Original entry on oeis.org

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

Views

Author

Gary W. Adamson, Sep 28 2007

Keywords

Examples

			a(5) = 1 = A007001(5) - A007001(4) = (3 - 2).
		

Crossrefs

Extensions

More terms from Colin Barker, Apr 19 2015

A133913 Array read by ascending antidiagonals generated from partial sums of A007001.

Original entry on oeis.org

1, 1, 2, 1, 3, 1, 1, 4, 4, 2, 1, 5, 8, 6, 3, 1, 6, 13, 14, 9, 1, 1, 7, 19, 27, 23, 10, 2, 1, 8, 26, 46, 50, 33, 12, 1, 1, 9, 34, 72, 96, 83, 45, 13, 2, 1, 10, 43, 106, 168, 179, 128, 58, 15, 3, 1, 11, 53, 149, 274, 347, 307, 186, 73, 18, 1, 1, 12, 64, 202, 423, 621, 654, 493, 259, 91
Offset: 1

Views

Author

Gary W. Adamson, Sep 28 2007

Keywords

Comments

Given A007001: (1, 2, 1, 2, 3, 1, 2, 1, ...) as first row of an array, n-th row = partial sum sequence of (n-1)-th row.
Row sums = A133914: (1, 3, 5, 11, 23, 44, 89, 177, 355, ...).
Right border = A007001: (1, 2, 1, 2, 3, 1, 2, 1, ...).

Examples

			First few rows of the array:
  1, 2,  1,  2,  3,   1,   2, ...
  1, 3,  4,  6,  9,  10,  12, ...
  1, 4,  8, 14, 23,  33,  45, ...
  1, 5, 13, 27, 50,  83, 128, ...
  1, 6, 19, 46, 96, 179, 307, ...
  ...
First few rows of the triangle:
  1;
  1,  2;
  1,  3,  1;
  1,  4,  4,   2;
  1,  5,  8,   6,   3;
  1,  6, 13,  14,   9,   1;
  1,  7, 19,  27,  23,  10,   2;
  1,  8, 26,  46,  50,  33,  12,  1;
  1,  9, 34,  72,  96,  83,  45, 13,  2;
  1, 10, 43, 106, 168, 179, 128, 58, 15, 3;
  ...
		

Crossrefs

Extensions

Edited by Jon E. Schoenfield, Mar 26 2022

A000245 a(n) = 3*(2*n)!/((n+2)!*(n-1)!).

Original entry on oeis.org

0, 1, 3, 9, 28, 90, 297, 1001, 3432, 11934, 41990, 149226, 534888, 1931540, 7020405, 25662825, 94287120, 347993910, 1289624490, 4796857230, 17902146600, 67016296620, 251577050010, 946844533674, 3572042254128, 13505406670700, 51166197843852, 194214400834356
Offset: 0

Views

Author

Keywords

Comments

This sequence represents the expected saturation of a binary search tree (or BST) on n nodes times the number of binary search trees on n nodes, or alternatively, the sum of the saturation of all binary search trees on n nodes. - Marko Riedel, Jan 24 2002
1->12, 2->123, 3->1234 etc. starting with 1, gives A007001: 1, 12, 12123, 12123121231234... summing the digits gives this sequence. - Miklos Kristof, Nov 05 2002
a(n-1) = number of n-th generation vertices in the tree of sequences with unit increase labeled by 2 (cf. Zoran Sunic reference). - Benoit Cloitre, Oct 07 2003
With offset 1, number of permutations beginning with 12 and avoiding 32-1.
Number of lattice paths from (0,0) to (n,n) with steps E=(1,0) and N=(0,1) which touch but do not cross the line x-y=1. - Herbert Kociemba, May 24 2004
a(n) is the number of Dyck (n+1)-paths that start with UU. For example, a(2)=3 counts UUUDDD, UUDUDD, UUDDUD. - David Callan, Dec 08 2004
a(n) is the number of Dyck (n+2)-paths that start with UUDU. For example, a(2)=3 counts UUDUDDUD, UUDUDUDD, UUDUUDDD. - David Scambler, Feb 14 2011
Hankel transform is (0,-1,-1,0,1,1,0,-1,-1,0,...). Hankel transform of a(n+1) is (1,0,-1,-1,0,1,1,0,-1,-1,0,...). - Paul Barry, Feb 08 2008
Starting with offset 1 = row sums of triangle A154558. - Gary W. Adamson, Jan 11 2009
Starting with offset 1 equals INVERT transform of A014137, partial sums of the Catalan numbers: (1, 2, 4, 9, 23, ...). - Gary W. Adamson, May 15 2009
With offset 1, a(n) is the binomial transform of the shortened Motzkin numbers: 1, 2, 4, 9, 21, 51, 127, 323, ... (A001006). - Aoife Hennessy (aoife.hennessy(AT)gmail.com), Sep 07 2009
The Catalan sequence convolved with its shifted variant, e.g. a(5) = 90 = (1, 1, 2, 5, 14) dot (42, 14, 5, 2, 1) = (42 + 14 + 10 + 10 + 14 ) = 90. - Gary W. Adamson, Nov 22 2011
a(n+2) = A214292(2*n+3,n). - Reinhard Zumkeller, Jul 12 2012
With offset 3, a(n) is the number of permutations on {1,2,...,n} that are 123-avoiding, i.e., do not contain a three term monotone subsequence, for which the first ascent is at positions (3,4); see Connolly link. There it is shown in general that the k-th Catalan Convolution is the number of 123-avoiding permutations for which the first ascent is at (k, k+1). (For n=k, the first ascent is defined to be at positions (k,k+1) if the permutation is the decreasing permutation with no ascents.) - Anant Godbole, Jan 17 2014
With offset 3, a(n)=number of permutations on {1,2,...,n} that are 123-avoiding and for which the integer n is in the 3rd spot; see Connolly link. For example, there are 297 123-avoiding permutations on n=9 at which the element 9 is in the third spot. - Anant Godbole, Jan 17 2014
With offset 1, a(n) is the number of North-East paths from (0,0) to (n+1,n+1) that bounce off y = x to the right exactly once but do not cross y = x vertically. Details can be found in Section 4.4 in Pan and Remmel's link. - Ran Pan, Feb 01 2016
The total number of returns (downsteps which end on the line y=0) within the set of all Dyck paths from (0,0) to (2n,0). - Cheyne Homberger, Sep 05 2016
a(n) is the number of intervals of the form [s,w] that are distributive (equivalently, modular) lattices in the weak order on S_n, for a fixed simple reflection s. - Bridget Tenner, Jan 16 2020
a(n+2) is the number of coalescent histories for a pair (G,S) where G is a gene tree with 3-pseudocaterpillar shape and n leaves, S is a species tree with caterpillar shape and n leaves, and G and S have identical leaf labeling. - Noah A Rosenberg, Jun 15 2022
a(n) is the number of parking functions of size n avoiding the patterns 132, 213, and 312. - Lara Pudwell, Apr 10 2023
a(n) is the number of parking functions of size n avoiding the patterns 123 and 213. - Lara Pudwell, Apr 10 2023

References

  • Pierre de la Harpe, Topics in Geometric Group Theory, Univ. Chicago Press, 2000, p. 11, coefficients of P_3(z).
  • Ki Hang Kim, Douglas G. Rogers and Fred W. Roush, Similarity relations and semiorders. Proceedings of the Tenth Southeastern Conference on Combinatorics, Graph Theory and Computing (Florida Atlantic Univ., Boca Raton, Fla., 1979), pp. 577-594, Congress. Numer., XXIII-XXIV, Utilitas Math., Winnipeg, Man., 1979. MR0561081 (81i:05013)
  • C. Krishnamachary and M. Bheemasena Rao, Determinants whose elements are Eulerian, prepared Bernoullian and other numbers, J. Indian Math. Soc., Vol. 14 (1922), pp. 55-62, 122-138 and 143-146.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

First differences of Catalan numbers A000108.
T(n, n+3) for n=0, 1, 2, ..., array T as in A047072.
Cf. A099364.
A diagonal of any of the essentially equivalent arrays A009766, A030237, A033184, A059365, A099039, A106566, A130020, A047072.
Column k=1 of A067323.

Programs

  • GAP
    Concatenation([0],List([1..30],n->3*Factorial(2*n)/(Factorial(n+2)*Factorial(n-1)))); # Muniru A Asiru, Aug 09 2018
  • Magma
    [0] cat [3*Factorial(2*n)/(Factorial(n+2)*Factorial(n-1)): n in [1..30]]; // Vincenzo Librandi, Feb 15 2016
    
  • Maple
    A000245 := n -> 3*binomial(2*n, n-1)/(n+2);
    seq(A000245(n), n=0..27);
  • Mathematica
    Table[3(2n)!/((n+2)!(n-1)!),{n,0,30}] (* or *) Table[3*Binomial[2n,n-1]/(n+2),{n,0,30}] (* or *) Differences[CatalanNumber[Range[0,31]]] (* Harvey P. Dale, Jul 13 2011 *)
  • PARI
    a(n)=if(n<1,0,3*(2*n)!/(n+2)!/(n-1)!)
    
  • Sage
    [catalan_number(i+1) - catalan_number(i) for i in range(28)] # Zerinvary Lajos, May 17 2009
    
  • Sage
    def A000245_list(n) :
        D = [0]*(n+1); D[1] = 1
        b = False; h = 1; R = []
        for i in range(2*n-1) :
            if b :
                for k in range(h,0,-1) : D[k] += D[k-1]
                h += 1; R.append(D[2])
            else :
                for k in range(1,h, 1) : D[k] += D[k+1]
            b = not b
        return R
    A000245_list(29) # Peter Luschny, Jun 03 2012
    

Formula

a(n) = A000108(n+1) - A000108(n).
G.f.: x*(c(x))^3 = (-1+(1-x)*c(x))/x, c(x) = g.f. for Catalan numbers. Also a(n) = 3*n*Catalan(n)/(n+2). - Wolfdieter Lang
For n > 1, a(n) = 3a(n-1) + Sum[a(k)*a(n-k-2), k=1,...,n-3]. - John W. Layman, Dec 13 2002; proved by Michael Somos, Jul 05 2003
G.f. is A(x) = C(x)*(1-x)/x-1/x = x(1+x*C(x)^2)*C(x)^2 where C(x) is g.f. for Catalan numbers, A000108.
G.f. satisfies x^2*A(x)^2 + (3*x-1)*A(x) + x = 0.
Series reversion of g.f. A(x) is -A(-x). - Michael Somos, Jan 21 2004
a(n+1) = Sum_{i+j+k=n} C(i)C(j)C(k) with i, j, k >= 0 and where C(k) denotes the k-th Catalan number. - Benoit Cloitre, Nov 09 2003
An inverse Chebyshev transform of x^2. - Paul Barry, Oct 13 2004
The sequence is 0, 0, 1, 0, 3, 0, 9, 0, ... with zeros restored. Second binomial transform of (-1)^n*A005322(n). The g.f. is transformed to x^2 under the Chebyshev transformation A(x)->(1/(1+x^2))A(x/(1+x^2)). For a sequence b(n), this corresponds to taking Sum_{k=0..floor(n/2)} C(n-k, k)(-1)^k*b(n-2k), or Sum_{k=0..n} C((n+k)/2, k)*b(k)*(-1)^((n-k)/2)*(1+(-1)^(n-k))/2. - Paul Barry, Oct 13 2004
G.f.: (c(x^2)*(1-x^2)-1)/x^2, c(x) the g.f. of A000108; a(n) = Sum_{k=0..n} (k+1)*C(n, (n-k)/2)*(-1)^k*(C(2,k)-2*C(1,k)+C(0, k))*(1+(-1)^(n-k))/(n+k+2). - Paul Barry, Oct 13 2004
a(n) = Sum_{k=0..n} binomial(n,k)*2^(n-k)*(-1)^(k+1)*binomial(k, floor((k-1)/2)). - Paul Barry, Feb 16 2006
E.g.f.: exp(2*x)*(Bessel_I(1,2x) - Bessel_I(2,2*x)). - Paul Barry, Jun 04 2007
a(n) = (1/Pi)*Integral_{x=0..4} x^n*(x-1)*sqrt(x*(4-x))/(2*x). - Paul Barry, Feb 08 2008
D-finite with recurrence: For n > 1, a(n+1) = 2*(2n+1)*(n+1)*a(n)/((n+3)*n). - Sean A. Irvine, Dec 09 2009
Let A be the Toeplitz matrix of order n defined by: A[i,i-1]=-1, A[i,j] = Catalan(j-i), (i<=j), and A[i,j] = 0, otherwise. Then, for n >= 2, a(n-1) = (-1)^(n-2)*coeff(charpoly(A,x),x^2). - Milan Janjic, Jul 08 2010
a(n) = sum of top row terms of M^(n-1), M = an infinite square production matrix as follows:
2, 1, 0, 0, 0, 0, ...
1, 1, 1, 0, 0, 0, ...
1, 1, 1, 1, 0, 0, ...
1, 1, 1, 1, 1, 0, ...
1, 1, 1, 1, 1, 1, ...
...
- Gary W. Adamson, Jul 14 2011
E.g.f.: exp(2*x)*(BesselI(2,2*x)) = Q(0) - 1 where Q(k) = 1 - 2*x/(k + 1 - 3*((k+1)^2)/((k^2) + 8*k + 9 - (k+2)*((k+3)^2)*(2*k+3)/((k+3)*(2*k+3) - 3*(k+1)/Q(k+1)))); (continued fraction). - Sergei N. Gladkovskii, Dec 05 2011
a(n) = -binomial(2*n,n)/(n+1)*hypergeom([-1,n+1/2],[n+2],4). - Peter Luschny, Aug 15 2012
a(n) = Sum_{i=0..n-1} C(i)*C(n-i), where C(i) denotes the i-th Catalan number. - Dmitry Kruchinin, Mar 02 2013
a(n) = binomial(2*n-1, n) - binomial(2*n-1, n-3). - Johannes W. Meijer, Jul 31 2013
a(n) ~ 3*4^n/(n^(3/2)*sqrt(Pi)). - Vaclav Kotesovec, Feb 26 2016
a(n) = ((-1)^n/(n+1))*Sum_{i=0..n-1} (-1)^(i+1)*(n+1-i)*binomial(2*n+2,i), n>=0. - Taras Goy, Aug 09 2018
From Amiram Eldar, Jan 02 2022: (Start)
Sum_{n>=1} 1/a(n) = 14*Pi/(27*sqrt(3)) + 5/9.
Sum_{n>=1} (-1)^(n+1)/a(n) = 164*log(phi)/(75*sqrt(5)) + 7/25, where phi is the golden ratio (A001622). (End)
a(n) = 3*Sum_{k = 0..n-2} (-1)^k * binomial(2*n-k-1, n+1)*binomial(n+1, k)/(k + 1) for n >= 2. - Peter Bala, Sep 02 2024
a(n) = (3*n/(n+2))*A000108(n). - Taras Goy, Dec 20 2024

Extensions

I changed the description and added an initial 0, to make this coincide with the first differences of the Catalan numbers A000108. Some of the other lines will need to be changed as a result. - N. J. A. Sloane, Oct 31 2003

A239903 List of Restricted-Growth Strings a_{k-1}a_{k-2}...a_{2}a_{1}, with k=2 and a_1 in {0,1} or k>2, a_{k-1}=1 and a_{j+1}>=1+a_j, for k-1>j>0.

Original entry on oeis.org

0, 1, 10, 11, 12, 100, 101, 110, 111, 112, 120, 121, 122, 123, 1000, 1001, 1010, 1011, 1012, 1100, 1101, 1110, 1111, 1112, 1120, 1121, 1122, 1123, 1200, 1201, 1210, 1211, 1212, 1220, 1221, 1222, 1223, 1230, 1231, 1232, 1233, 1234, 10000, 10001, 10010, 10011
Offset: 0

Views

Author

N. J. A. Sloane, Apr 06 2014

Keywords

Comments

We write the nonnegative integers as restricted growth strings (so called by J. Arndt in his book fxtbook.pdf, p. 325) in such a way that the Catalan numbers (cf. A000108) are expressed: 1=1, 10=2, 100=5, 1000=14, etc., 10...0 (with k zeros) = the k-th Catalan number. Once the entries of a restricted-growth string grow above 9, one would need commas or parentheses, say, to separate those entries. See Dejter (2017) for the precise definition.
In the paper "A system of numeration for middle-levels", restricted growth strings (RGSs) are defined as sequences that begin with either 0 or 1, with each successive number to the right being at least zero and at most one greater than its immediate left neighbor. Moreover, apart from case a(0), the RGSs are finite integer sequences of restricted growth which always start with 1 as their first element b_1 in position 1, and from then on, each successive element b_{i+1} in the sequence is restricted to be in range [0,(b_i)+1].
This sequence gives all such finite sequences in size-wise and lexicographic order, represented as decimal numbers by concatenating the integers of such finite sequences (e.g., from [1,2,0,1] we get 1201). The 58784th such sequence is [1, 2, 3, 4, 5, 6, 7, 8, 9, 9], thus a(58784) = 1234567899, after which comes the first RGS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], where an element larger than 9 is present, which means that the decimal system employed here is unambiguous only up to n=58784. Note that 58785 = A000108(11)-1.
Also, if one considers Stanley's interpretation (u) of Catalan numbers, "sequences of a_1, a_2, ..., a_n of integers such that a_1 = 0 and 0 <= a_{i+1} <= a_{i} + 1" (e.g., 000, 001, 010, 011, 012 for C_3), and discards their initial zero, then one has a bijective correspondence with Dejter's RGSs of one element shorter length, which in turn are in bijective correspondence with the first C_n terms of this sequence (by discarding any leading zeros), from a(0) to a(C_n - 1). From this follows that the k-th Catalan number, A000108(k) (k>0), is represented in this system as 1 followed by k-1 zeros: a(1)=1, a(2)=10, a(5)=100, a(14)=1000, etc., and also that there exist exactly A000245(k) RGSs of length k.
Note how this differs from other number representations utilizing Catalan numbers, A014418 and A244159, in that while the latter are base-systems, where a simple weighted Sum_{k} digit(k)*C(k) recovers the natural number n (which the n-th numeral of such system represents), in contrast here it is the sum of appropriate terms in Catalan's Triangle (A009766, A030237), obtained by unranking a unique instance of a certain combinatorial structure (one of the Catalan interpretations), that gives a correspondence with a unique natural number. (Cf. also A014486.)
This sequence differs from "Semigreedy Catalan Representation", A244159, for the first time at n=10, where a(10) = 120, while A244159(10) = 121. That is also the first position where A244158(a(n)) <> n.
Please see Dejter's preprint for a more formal mathematical definition and how this number system is applied in relation to Havel's Conjecture on the existence of Hamiltonian cycles in the middle-levels graphs.
a(n) is given by the concatenation (with leading zeros removed) of the terms of row n + 23714 of A370222. - Paolo Xausa, Feb 17 2024

Examples

			Catalan's Triangle T(row,col) = A009766 begins with row n=0 and 0<=col<=n as:
  Row 0: 1
  Row 1: 1, 1
  Row 2: 1, 2,  2
  Row 3: 1, 3,  5,  5
  Row 4: 1, 4,  9, 14, 14
  Row 5: 1, 5, 14, 28, 42,  42
  Row 6: 1, 6, 20, 48, 90, 132, 132
  (the leftmost diagonal of 1s is "column 0").
  ...
For example, for n=38, we find that A081290(38)=14, which occurs on row A081288(n)-1 = 4, in columns A081288(n)-1 and A081288(n)-2, i.e., as T(4,4) and T(4,3). Thus we subtract 38-14 to get 24, and we see that the next term downward on the same diagonal, 28, is too large to accommodate into the same sum, so we go one diagonal up, starting now from T(3,2) = 5. This fits in, so we now have 24 - 5 = 19, and also the next term on the same diagonal, T(4,2) = 9, fits in, so we now have 19-9 = 10. The next term on the same diagonal, T(5,2) = 14, would not fit in anymore, so we rewind ourselves back to penultimate column, but one step up from where we started on this diagonal, so T(2,1) = 2, which fits in, 10 - 2 = 8, also the next one T(3,1) = 3, 8 - 3 = 5, and the next one T(4,1) = 4, 5 - 4 = 1, after which comes T(5,1) = 5 > 1, thus we jump to T(1,0) = 1, 1-1 = 0, and T(2,0)=1 would not fit anymore, thus next time the row would be zero, and the algorithm is ready with 1 (14), 2 (5+9), 3 (2+3+4) and 1 (1) terms collected, whose total sum 14+5+9+2+3+4+1 = 38, thus a(38) = 1231.
For n=20, the same algorithm results in 1 (14), 1 (5), 0 (not even the first tentative term T(2,1) = 2 from the column 1 would fit, so it is skipped), and from one row higher we get the needed 1 (1), so the total sum of these is 14+5+0+1 = 20, thus a(20) = 1101.
		

References

  • D. E. Knuth, The Art of Computer Programming, Vol. 2: Seminumerical Algorithms, third edition, Addison-Wesley, 1977, p. 192.
  • R. P. Stanley, Enumerative Combinatorics, Cambridge, Vol. 2, 1999, Exercise 19, interpretation (u).

Crossrefs

Cf. A000108 (Catalan numbers), A000245 (their first differences), A009766 (Catalan's triangle), A236855 (the sum of elements in k-th RGS), A236859 (for n>=1, gives the length of the initial ascent 123... in term a(n)), A244159 (different kinds of Catalan number systems).
Other Catalan combinatorial structures represented as integer sequences: A014486/A063171: Dyck words, parenthesizations, etc., A071156/A071158: Similar restricted words encoded with help of A007623 (Integers written in factorial base), A071153/A079436 (Łukasiewicz words).

Programs

  • Julia
    function CatalanNumerals(z)
        z == 0 && return 0
        f(n) = factorial(n)
        t(j, k) = div(f(k+j)*(k-j+1), f(j)*f(k+1))
        k, i = 2, 0
        while z >= t(i, i + 1) i += 1 end
        dig = fill(0, i); dig[1] = 1
        x = z - t(i - 1, i)
        m = i - 1
        while x > 0
            w, s, p = 0, 0, 0
            while w <= x
                p = w
                w += t(m - 1, m + s)
                s += 1
            end
            dig[k] = s - 1
            m -= 1; k += 1; x -= p
        end
        s = ""; for d in dig s *= string(d) end
        parse(Int, s)
    end
    [CatalanNumerals(n) for n in 0:42] |> println # Peter Luschny, Nov 10 2019
    
  • MATLAB
    function [ c ] = catrep(z)
    i=0; x=0; y=0; s=0;
    while z>=(factorial(2*i+1)*(2))/(factorial(i)*factorial(i+2))
    i=i+1;
    end
    y=(factorial(2*i-1)*(2))/(factorial(i-1)*factorial(i+1));
    a=zeros(1,i); a(1,1)=1; k=2; x=z-y; m=1;
    while x>0
    w=0; s=0; p=0;
    while w<=x
    p=w;
    w=w+(factorial(2*i-2*m+s-1)*(s+2))/(factorial(i-1-m)*factorial(i-m+s+1));
    s=s+1;
    end
    m=m+1; a(1,k)=s-1; k=k+1; x=x-p;
    end
    a
    end
    
  • Mathematica
    A239903full = With[{r = 2*Range[2, 11]-1}, Reverse[Map[FromDigits[r-#] &, Rest[Select[Subsets[Range[2, 21], {10}, 125477], Min[r-#] >= 0 &]]]]];
    A239903full[[;;100]] (* Paolo Xausa, Feb 17 2024 *)
  • Maxima
    define (t(j,k), (factorial(k+j)*(k-j+1))/(factorial(j)*factorial(k+1)));
    i:0;
    x:19;
    z:0;y:0;s:0;
    while x>=t(i,i+1) do (i:i+1);
    y:t(i-1,i);a:zeromatrix(1,i);a[1,1]:1;k:2;z:x-y;m:1;
    while (z>0) do (
    w:0,s:0,p=0,
    while (w<=z) do (
    p:w,
    w:w+t(i-1-m,i-m+s),
    s:s+1
    ),
    m:m+1,
    a[1,k]:s-1,k:k+1,
    z:z-p
    );
    print(a);
    
  • PARI
    \\ Valid for n<58786 (=A000108(11)).
    nxt(w)=if(w[1]==#w, vector(#w+1, i, i>#w), my(k=1); while(w[k]>w[k+1], w[k]=0; k++); w[k]++; w)
    seq(n)={my(a=vector(n), w=[1]); a[1]=0; for(i=2, #v, a[i]=fromdigits(Vecrev(w)); w=nxt(w)); a} \\ Andrew Howroyd, Jan 24 2023
  • Scheme
    (define (A239903_only_upto_16794 n) (if (zero? n) n (A235049 (A071159 (A081291 n))))) ;; Gives correct results only up to 16794.
    ;; The following gives correct results all the way up to n=58784.
    (define (A239903 n) (baselist-as-decimal (A239903raw n)))
    (definec (A239903raw n) (if (zero? n) (list) (let loop ((n n) (row (A244160 n)) (col (- (A244160 n) 1)) (srow (- (A244160 n) 1)) (catstring (list 0))) (cond ((or (zero? row) (negative? col)) (reverse! (cdr catstring))) ((> (A009766tr row col) n) (loop n srow (- col 1) (- srow 1) (cons 0 catstring))) (else (loop (- n (A009766tr row col)) (+ row 1) col srow (cons (+ 1 (car catstring)) (cdr catstring))))))))
    (define (baselist-as-decimal lista) (baselist->n 10 lista))
    (define (baselist->n base bex) (let loop ((bex bex) (n 0)) (cond ((null? bex) n) (else (loop (cdr bex) (+ (* n base) (car bex)))))))
    ;; From Antti Karttunen, Apr 14-19 2014
    

Formula

To find an RGS corresponding to natural number n, one first finds a maximum row index k such that T(k,k-1) <= n in the Catalan Triangle (A009766) illustrated in the Example section. Note that as the last two columns of this triangle consist of Catalan numbers (that is, T(k,k-1) = T(k,k) = A000108(k)), it means that the first number to be subtracted from n is A081290(n) which occurs as a penultimate element of the row A081288(n)-1, in the column A081288(n)-2. The unranking algorithm then proceeds diagonally downwards, keeping the column index the same, and incrementing the row index, as long as it will encounter terms such that their total sum stays less than or equal to n.
If the total sum of encountered terms on that diagonal would exceed n, the algorithm jumps back to the penultimate column of the triangle, but one row higher from where it started the last time, and again starts summing the terms as long as the total sum stays <= n.
When the algorithm eventually reaches either row zero or column less than zero, the result will be a list of numbers, each element being the number of terms summed from each diagonal, so that the diagonal first traversed appears as the first 1 (as that first diagonal will never allow more than one term), and the number of terms summed from the last traversed diagonal appears the last number in the list. These lists of numbers are then concatenated together as decimal numbers.
These steps can also be played backwards in order to recover the corresponding decimal integer n from such a list of numbers, giving a "ranking function" which will be the inverse to this "unranking function".
For n=1..16794 (where 16794 = A000108(10)-2), a(n) = A235049(A071159(A081291(n))). - Antti Karttunen, Apr 14 2014
Alternative, simpler description of the algorithm from Antti Karttunen, Apr 21 2014: (Start)
Consider the following square array, which is Catalan triangle A009766 without its rightmost, "duplicate" column, appropriately transposed (cf. also tables A030237, A033184 and A054445):
Row| Terms on that row
---+--------------------------
1 | 1 1 1 1 1 ...
2 | 2 3 4 5 6 ...
3 | 5 9 14 20 27 ...
4 | 14 28 48 75 110 ...
5 | 42 90 165 275 429 ...
6 | 132 297 572 1001 1638 ...
To compute the n-th RGS, search first for the greatest Catalan number C_k which is <= n (this is A081290(n), found as the first term of row A081288(n)-1). Then, by a greedy algorithm, select from each successive row (moving towards the top of table) as many terms from the beginning of that row as will still fit into n, subtracting them from n as you go. The number of terms selected from the beginning of each row gives each element of the n-th RGS, so that the number of terms selected from the topmost row (all 1's) appears as its last element.
(End)

Extensions

Description, formula and examples edited/rewritten by Italo J Dejter, Apr 13 2014 and Antti Karttunen, Apr 18 2014

A080237 Start with 1 and apply the process: k-th run is 1, 2, 3, ..., a(k-1)+1.

Original entry on oeis.org

1, 1, 2, 1, 2, 1, 2, 3, 1, 2, 1, 2, 3, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 1, 2, 3, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 1, 2, 3, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 1, 2, 3, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 1, 2, 3, 1, 2, 1, 2
Offset: 1

Views

Author

Benoit Cloitre, Mar 18 2003

Keywords

Comments

Also a triangle collected from the Catalan generating tree, with row n containing A000108(n) terms and ending with n. Rows converge towards A007001, the "last" row. - Antti Karttunen, Jun 17 2003

Examples

			As an irregular triangle:
  1;
  1,2;
  1,2,1,2,3;
  1,2,1,2,3,1,2,1,2,3,1,2,3,4;
  ...
Sequence begins: 1,(1,2),(1,2),(1,2,3), ... where runs are between 2 parentheses. 5th run is (1,2) since a(4)=1 and sequence continues: 1,1,2,1,2,1,2,3,1,2....
G.f. = x + x^2 + 2*x^3 + x^4 + 2*x^5 + x^6 + 2*x^7 + 3*x^8 + x^9 + 2*x^10 + ...
		

Crossrefs

Cf. A000002, A007001. Positions of ones: A085223. The first occurrence of each n is at A014138(n). See A085178.

Programs

  • Haskell
    a080237 n k = a080237_tabf !! (n-1) !! (k-1)
    a080237_row n = a080237_tabf !! (n-1)
    a080237_tabf = [1] : f a080237_tabf where
       f [[]] =[]
       f (xs:xss) = concatMap (enumFromTo 1 . (+ 1)) xs : f xss
    a080237_list = concat a080237_tabf
    -- Reinhard Zumkeller, Jun 01 2015
  • Mathematica
    run[1] = {1}; run[k_] := run[k] = Range[ Flatten[ Table[run[j], {j, 1, k-1}]][[k-1]] + 1]; Table[run[k], {k, 1, 29}] // Flatten (* Jean-François Alcover, Sep 12 2012 *)
    NestList[ Flatten[# /. # -> Range[# + 1]] &, {1}, 5] // Flatten (* Robert G. Wilson v, Jun 24 2014 *)
  • PARI
    {a(n) = my(v, i, j, k); if( n<1, 0, v=vector(n); for(m=1, n, v[m]=k++; if( k>j, j=v[i++]; k=0)); v[n])}; /* Michael Somos, Jun 24 2014 */
    

Formula

It seems that Sum_{k=1..n} a(k) = C*n*log(log(n)) + O(n*log(log(n))) with C = 0.6....
a(n) = A007814(A014486(n)) (i.e., number of trailing zeros in A063171(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)
Showing 1-10 of 15 results. Next