The guide
One sequence, many shapes: why brackets, trees and triangles all count 1, 1, 2, 5, 14
Catalan numbers count balanced brackets, binary trees and polygon cuts alike. One short recurrence explains why the same numbers keep turning up, and exact arithmetic keeps every digit.
- 14 ways to cut a hexagon into triangles with diagonals
- 31 first n where C(n) no longer fits a plain double exactly
- 3,005 digits in C(5000)
- 0.988862 C(100) over its growth estimate (approximate)
- 4 the number the ratio of neighbouring terms climbs toward
Read the full guide Fold the guide
Write down every way to close three pairs of brackets correctly and you get five strings: ((())), (()()), (())(), ()(()) and ()()(). Cut a hexagon into triangles with diagonals that never cross and you get fourteen pictures. Those two counts look unrelated. They belong to one sequence, 1, 1, 2, 5, 14, 42, 132, 429, and the surprise is how many unrelated problems end up there.
One list, many names
The sequence is called the Catalan numbers. The Wikipedia article on them describes a sequence of natural numbers that turn up in counting problems, often ones built from recursively defined objects. It adds that Richard Stanley’s book on enumerative combinatorics collects 66 different interpretations. The NIST Digital Library of Mathematical Functions repeats that figure, noting sixty-six equivalent definitions in the same book.
Some of those definitions are easy to picture. A string of n pairs of brackets that close properly is counted. So is a path of n steps up and n steps down that never dips below the ground. So is a full binary tree with n inner nodes, a way to put brackets round a product of n plus one factors, and a way to cut a polygon with n plus two sides into triangles.
Non-crossing groups count too. Place n points round a circle and split them into groups whose outlines do not cross; the number of ways is again a Catalan number. The On-Line Encyclopedia of Integer Sequences lists the same family: for four points it notes that only one of the fifteen set partitions crosses, leaving fourteen.
A confusing habit is the index. The fifth number in the list is C(4) = 14, not C(5), because counting starts at C(0) = 1. Three pairs of brackets give C(3) = 5.
Why the same numbers appear
The reason is a shared way of splitting. Take a correct string of brackets and look at its first opening bracket. It is closed by one particular bracket later on. Everything between the two is itself a correct string, and everything after is another one. Wikipedia’s first proof of the formula uses this: every non-empty balanced word splits in exactly one way into an opening bracket, a smaller balanced word, a closing bracket and a second smaller word.
Count the ways. If the inner part uses i pairs, the part after uses the rest, and the two choices are independent. So C(n) is the sum of C(i) times C(n-1-i) for i from 0 to n-1. DLMF gives the same convolution as its recurrence. The tool computes this sum with big integers and checks it against three other routes.
Take n = 4. The inner part can hold 0, 1, 2 or 3 pairs, giving C(0) x C(3) + C(1) x C(2) + C(2) x C(1) + C(3) x C(0), which is 5 + 2 + 2 + 5 = 14. Enter 4 in the tool and the line appears with those numbers filled in.
Now trees. A binary tree splits at its root into a left subtree and a right subtree, the same pattern of an independent left part and right part. Wikipedia says that all the counting problems it lists satisfy this recurrence, and the tool’s lists let you check it for the other shapes by eye. Different objects, one recurrence, one answer. That is why the sequence recurs. The problems are not coincidentally equal; each hides the same split. Wikipedia works the decomposition out for brackets, and the tool lets you test the other cases by listing every object and counting it, rather than trusting the formula to do the counting.
Wikipedia states the tree case precisely: C(n) counts full binary trees with n inner nodes, which have n plus one leaves. The gallery draws the nodes as round dots and the leaves as small boxes.
The closed form and its two faces
Splitting gives a recurrence, which is slow to evaluate by hand. A closed form is quicker. According to Wikipedia and DLMF, C(n) equals the central binomial coefficient (2n choose n), divided by n plus one. For n = 4 that is 70 divided by 5, which is 14.
There is a second face of the same number. Wikipedia gives the alternative C(n) = (2n choose n) minus (2n choose n+1), and notes it shows at once that C(n) is a whole number, which the division form does not. For n = 4 the difference is 70 minus 56, again 14. The tool prints both lines with your n and the real binomials, shortened with their digit counts when they are long. DLMF’s section on binomial coefficients shows where the subtraction comes from: paths that stay on or above the diagonal number one binomial coefficient minus another.
Behind both forms sits the binomial coefficient. The Wikipedia article on binomial coefficients gives the multiplicative formula, a product of fractions in which the numerator counts ordered choices and the denominator removes the order. The tool uses that formula, so every partial result stays a whole number, and the division at each step is exact. A third route is cheaper still. Wikipedia lists the recurrence C(n) = 2(2n-1) / (n+1) times C(n-1). Each term is the previous one times a small fraction, so the tool can build the whole list from C(0) with one multiplication and one exact division per step. The ratio of neighbouring terms is that fraction in lowest terms.
Growth, and why exact arithmetic matters
That fraction explains how fast the numbers grow. At n = 20 it is 2 x 39 / 21, about 3.71. At n = 100 it is about 3.94, and at n = 5000 it is about 3.9988. DLMF states the limit: the ratio of C(n+1) to C(n) tends to 4. Each step multiplies the value by a little less than four.
Wikipedia and DLMF also give an estimate. C(n) behaves like 4^n divided by n^(3/2) times the square root of pi, in the sense that the quotient tends to 1. The estimate is approximate, and for finite n it is not exact. At n = 100 the tool gives a ratio of 0.988862, a little below 1, so the estimate is slightly too large at that size.
Growth like that outruns ordinary arithmetic quickly. The MDN page on Number.MAX_SAFE_INTEGER gives the largest whole number a plain double represents exactly: 9,007,199,254,740,991. C(30) is 3,814,986,502,092,304, which still fits. C(31) is 14,544,636,039,226,909, which does not. A calculator that uses doubles starts to drop low digits at n = 31 and may print a value that looks plausible and is wrong.
The remedy is BigInt, which MDN describes as a type for integers too high or too low for the number type. With it, C(100) is exactly 896519947090131496687170070074100632420837521538745909320, a number of 57 digits, and C(5000) has 3,005 digits, all exact.
Big integers are not free. Computing C(5000) by four routes multiplies and divides numbers thousands of digits long. The work is quick, but the tool hands it to a Web Worker so that typing never waits. MDN explains that a worker runs a script in a background thread so the main thread stays unblocked, and the page stays responsive.
What the tool lists, and what it cannot do
The gallery draws objects for n from 0 to 6. At n = 6 there are 132 of each kind, and no list is made by the formula. Brackets are produced by generating every arrangement of n opening and n closing brackets and keeping those whose running count never goes negative. Triangulations are found by testing sets of non-crossing diagonals.
Each list is then compared with C(n). If the count of valid hexagon triangulations were 6, as a careless guess might say, the check would show a mismatch. It shows 14, equal to the formula. The same holds for brackets, paths, trees, products and circle groups for every n up to the cap.
The limits are plain. The tool does not draw objects beyond n = 6, it does not prove the growth estimate, and it does not count other families such as arrangements of distinct items. For choosing and ordering items, the Permutation and Combination Calculator is the better page. The numbers it prints come from exact integers; the one approximation, the ratio to the estimate, is labelled as approximate.
Stanley keeps a Catalan Addendum that extends the exercise list from his book with further combinatorial interpretations. His history of the field also records that John Riordan gave the sequence its name. Wikipedia adds that Minggatu found the numbers in the 1730s, that Euler studied polygon division in 1751, and that Catalan came to the sequence through bracketed expressions. MacTutor notes that a paper of Catalan’s on a finite difference equation contains the numbers in the solution of cutting a polygon into triangles.
A sequence that begins with a handful of small values opens a door to a vast family of problems. Start with n = 3 and count five strings, then try n = 4 and watch fourteen hexagon cuts appear. Then ask for n = 5000 and meet a number that fills a screen.
Sources
Every source consulted for this guide. Links checked November 10, 2026.
- Catalan number - Wikipedia Wikipedia (CC BY-SA 4.0)
- Binomial coefficient - Wikipedia Wikipedia (CC BY-SA 4.0)
- A000108 - OEIS The On-Line Encyclopedia of Integer Sequences (CC BY-SA 4.0)
- DLMF: 26.5 Lattice Paths: Catalan Numbers NIST Digital Library of Mathematical Functions (US government)
- DLMF: 26.3 Lattice Paths: Binomial Coefficients NIST Digital Library of Mathematical Functions (US government)
- Eugène Catalan (1814 - 1894) - Biography - MacTutor History of Mathematics MacTutor, University of St Andrews (CC BY-SA 4.0)
- Enumerative and Algebraic Combinatorics in the 1960's and 1970's Richard P. Stanley, arXiv (CC BY 4.0)
- Catalan Addendum Richard P. Stanley, Massachusetts Institute of Technology (no licence stated)
- BigInt - JavaScript | MDN MDN Web Docs (Creative Commons licence)
- Number.MAX_SAFE_INTEGER - JavaScript | MDN MDN Web Docs (Creative Commons licence)
- Web Workers API - Web APIs | MDN MDN Web Docs (Creative Commons licence)