

A239903


List of Catalan numerals.


12



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
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,3


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 kth Catalan number. Once the "digits" grow above 9 one needs commas to separate the digits. 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 sizewise 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 kth Catalan number, A000108(k) (k>0), is represented in this system as 1 followed by k1 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 basesystems, where a simple weighted Sum_{k} digit(k)*C(k) recovers the natural number n (which the nth 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 middlelevels graphs.


REFERENCES

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


LINKS

Antti Karttunen, Table of n, a(n) for n = 0..16796
J. Arndt, Matters Computational: Ideas, Algorithm, Source Code, Springer, 2011; freely downloadable here: Fxtbook.
Georg Cantor, Über die einfachen Zahlensysteme, Zeitschrift fur Mathematik und Physik, 14 (1869), 121128.
Italo J. Dejter, A system of numeration for middle levels, arXiv:1012.0995 [math.CO], (2014).
Italo J. Dejter, The role of restricted growth strings in the two middle levels of the Boolean lattice B_(2k+1), University of Puerto Rico, 2018.
Aviezri S. Fraenkel, The Use and Usefulness of Numeration Systems, Inf. Comput., 81(1), (1989), 4661.
Aviezri S. Fraenkel, Systems of numeration, IEEE Symposium on Computer Arithmetic, (1983), 3742.
Aviezri S. Fraenkel, Systems of numeration, The American Mathematical Monthly, Vol. 92, No. 2 (Feb., 1985), pp. 105114.
Antti Karttunen, Catalan ranking and unranking functions, OEIS Wiki.
R. P. Stanley, Exercises on Catalan and Related Numbers, interpretation (u) of Catalan numbers, on page 224 (page 4/27 in the November 1 2000 version of the PDFfile).


FORMULA

To find an RGS corresponding to natural number n, one first finds a maximum row index k such that T(k,k1) <= 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,k1) = 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 nth 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 nth RGS, so that the number of terms selected from the topmost row (all 1's) appears as its last element.
(End)


EXAMPLE

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 3814 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 199 = 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, 11 = 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.


PROG

(MAXIMA)
define (t(j, k), (factorial(k+j)*(kj+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(i1, i); a:zeromatrix(1, i); a[1, 1]:1; k:2; z:xy; m:1;
while (z>0) do (
w:0, s:0, p=0,
while (w<=z) do (
p:w,
w:w+t(i1m, im+s),
s:s+1
),
m:m+1,
a[1, k]:s1, k:k+1,
z:zp
);
print(a);
(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*i1)*(2))/(factorial(i1)*factorial(i+1));
a=zeros(1, i); a(1, 1)=1; k=2; x=zy; m=1;
while x>0
w=0; s=0; p=0;
while w<=x
p=w;
w=w+(factorial(2*i2*m+s1)*(s+2))/(factorial(i1m)*factorial(im+s+1));
s=s+1;
end
m=m+1; a(1, k)=s1; k=k+1; x=xp;
end
a
end
(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) (baselistasdecimal (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 (baselistasdecimal 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 1419 2014


CROSSREFS

Cf. A000108 (Catalan numbers), A000245 (their first differences), A009766 (Catalan's triangle), A236855 (the sum of elements in kth 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).
Cf. A007001, A007623, A014418, A071154, A071159, A081288, A081290, A081291, A082853, A126307, A244155, A244156, A244157, A244158.
Sequence in context: A048002 A256523 A125098 * A244159 A171752 A058944
Adjacent sequences: A239900 A239901 A239902 * A239904 A239905 A239906


KEYWORD

nonn,base,changed


AUTHOR

N. J. A. Sloane, Apr 06 2014


EXTENSIONS

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


STATUS

approved



