Skip to content
math

Catalan Number Calculator

Compute the nth Catalan number — counts valid bracket sequences, binary-tree shapes, and more.

Catalan number C(5)
42
Cₙ = (1 / (n + 1)) · C(2n, n). Catalan numbers count combinatorial structures such as valid bracket sequences and distinct binary-tree shapes.

How it works

  1. 1Enter an index n between 0 and 25. The input is clamped automatically so no out-of-range value is accepted.
  2. 2The calculator applies Cₙ = (1 / (n + 1)) · C(2n, n), multiplying iteratively to stay within safe-integer bounds.
  3. 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.

See all →