Catalan Number Calculator
Compute the nth Catalan number — counts valid bracket sequences, binary-tree shapes, and more.
How it works
- 1Enter an index n between 0 and 25. The input is clamped automatically so no out-of-range value is accepted.
- 2The calculator applies Cₙ = (1 / (n + 1)) · C(2n, n), multiplying iteratively to stay within safe-integer bounds.
- 3The result is the exact nth Catalan number — the count of structurally distinct objects such as valid bracket sequences.
Use cases
- Verify hand calculations of Catalan numbers when studying combinatorics or preparing for competitive programming.
- Estimate the number of distinct full binary trees with n + 1 leaves for algorithm-design planning.
- Cross-check the number of valid bracket strings of length 2n to validate a parser or grammar exercise.
Frequently asked questions
What is a Catalan number?
The nth Catalan number Cₙ = (1 / (n + 1)) · C(2n, n) counts many structures at once: valid sequences of n bracket pairs, full binary trees with n + 1 leaves, and triangulations of a convex polygon with n + 2 sides.
Why is the calculator limited to n ≤ 25?
C(25) = 5,909,761,445,129,385,600, within JavaScript’s safe-integer range (≈ 9 × 10¹⁵). At n = 26 the exact value would exceed that limit and be silently rounded, so 25 is the safe bound.
How does the formula work?
C(2n, n) is the central binomial coefficient. Dividing by (n + 1) removes the unmatched sequences, leaving only the valid ones. The product is built incrementally to avoid overflow.
Related tools
See all →Calculate the area and perimeter of a rectangle from its width and height, with a labeled diagram.
Calculate the area and circumference of a circle from its radius, with a labeled diagram.
Calculate the area (Heron’s formula) and perimeter of a triangle from its three sides.
Calculate the area and perimeter of a trapezoid from its two parallel sides, height, and legs.