Motzkin and Narayana Numbers

Motzkin and Narayana numbers, counted and checked.

  • Motzkin to n = 400
  • Narayana triangle
  • Dyck paths checked
A small rounded clay table with a soft path of rounded beads that climbs and falls along the ground without dipping below it, with a few flat stretches.

The guide

Chords that never cross: how Motzkin and Narayana numbers count the same shapes

Motzkin paths, non-crossing chords and Dyck words are views of two tidy families of integers. Exact arithmetic checks every count, and only four Motzkin numbers are known to be prime.

  • 2,188 Motzkin paths with 10 steps
  • 5,292 Dyck words of 10 pairs with 5 peaks
  • 4 Motzkin primes known
  • 188 digits in M(400)
  • 0.976135 M(100) over its growth form (approximate)
Read the full guide Fold the guide 7 min · 12 sources

Put four points on a circle and join some of them with chords that must not cross. You may leave points alone. Count the different drawings and you get nine. Five points give twenty-one. Those two counts begin a sequence, 1, 1, 2, 4, 9, 21, 51, 127, 323, 835, and a second family of numbers, the Narayana triangle, turns out to be closely tied to it through the better-known Catalan numbers.

Chords, steps and levels

The Wikipedia article on Motzkin numbers defines the nth one as the number of ways to draw non-intersecting chords between n points on a circle, without needing to touch every point. The sequence is named after Theodore Motzkin, and the article dates his paper on the subject to 1948. The numbers are the same ones the On-Line Encyclopedia of Integer Sequences lists under A001006.

Motzkin was born in Berlin in 1908. According to the biography on Wikipedia he joined the Hebrew University in 1935, worked as a cryptographer for the British government during the war and moved to the United States in 1948. The Catalan number article also credits him, with Dvoretzky, for the cycle lemma used in one proof of the Catalan formula.

The same count has a walking reading. Wikipedia describes routes from (0, 0) to (n, 0) in n steps, where each step goes up, goes straight or goes down, and the route never dips below the axis. For n = 4 its figure shows nine such paths. Write U for up, H for level and D for down: UUDD, UDUD and UHDH are three of the nine.

Reading a path as chords is bookkeeping, and the reading is this tool’s own. Walk along the points one at a time. A U opens a chord at that point, a D closes the most recent chord still open, and an H leaves the point alone. UUDD becomes a long chord from point 1 to point 4 with a short one from 2 to 3 inside it.

A crossing pair, 1 to 3 together with 2 to 4, never appears, because a D always closes the newest chord first. The tool checks the reading by counting chord sets directly on n points, with no paths involved, for every n up to 10. The two counts agree each time.

Three formulas, one count

Wikipedia gives two recurrences. One adds up products: M(n) equals M(n-1) plus the sum of M(i) times M(n-2-i) for i from 0 to n-2. The other needs only the two previous terms: M(n) equals (2n + 1) times M(n-1) plus (3n - 3) times M(n-2), all divided by n + 2.

Why does the first one hold? Look at point 1. Either no chord touches it, which leaves M(n-1) drawings of the rest, or a chord joins it to a later point. That chord splits the remaining points into those inside it and those outside, and the two groups are drawn independently. Summing over every partner gives the products. This argument is mine; the tool tests it by computing.

The second recurrence is the faster one, and the division is always exact, a fact the tool checks by testing every remainder for zero. Try n = 4. Nine times M(3) is 36, nine times M(2) is 18, the sum is 54, and 54 divided by 6 is 9. Enter 4 in the tool and the line appears with those numbers filled in.

A third route ties Motzkin numbers to Catalan numbers. Wikipedia writes M(n) as the sum over k of (n choose 2k) times the kth Catalan number. A reading that makes it plausible: choose which 2k of the n points carry chords, then pair them up without crossing. For n = 4 that is 1 + 6 x 1 + 1 x 2, which is 9 again.

The relation also runs backwards. Wikipedia states that the Catalan number C(n+1) is the sum over k of (n choose k) times M(k). For n = 3 that reads 1 + 3 + 6 + 4, which is 14, the Catalan number C(4). The tool computes this identity for every n you enter and shows both sides. Three routes that share no steps and give the same integer are strong evidence that none of them has a slip. The tool prints MATCH or MISMATCH beside them in words, not in colour alone.

Wikipedia also gives an integral form, with sin squared of x times (2 cos x + 1) to the power n, and an asymptotic form, M(n) close to one over two square roots of pi, times (3/n) to the power 3/2, times 3 to the power n. The ratio of neighbouring terms therefore climbs toward 3. At n = 10 it is 2.62, at n = 100 about 2.9558, and at n = 400 about 2.9888. Against the asymptotic form the true value approaches 1 from below. At n = 100 the ratio is about 0.976135 and at n = 400 about 0.993939. Both are approximate figures from double arithmetic, and the tool labels them so.

Exactness matters sooner than you might expect. The largest whole number a plain double holds exactly is 9,007,199,254,740,991, and M(39) = 22,944,749,046,030,949 is the first Motzkin number above it. MDN describes BigInt as the type for integers too large to fit the number type, and the tool uses it everywhere. M(100) has 45 digits and M(400) has 188.

Narayana numbers split the Catalan count

The Narayana numbers form a triangle named after T. V. Narayana, a Canadian mathematician who lived from 1930 to 1987, according to Wikipedia. The article gives N(n, k) as (1/n) times (n choose k) times (n choose k-1), and lists the first eight rows. Row 4 reads 1, 6, 6, 1. Row 8 reads 1, 28, 196, 490, 490, 196, 28, 1.

The counting meaning is about brackets. A Dyck word is a string of n pairs of brackets that close correctly, and Wikipedia says N(n, k) counts those with exactly k occurrences of the pair ”()”. It lists the six words with four pairs and two such occurrences, so N(4, 2) = 6. Read ( as a step up and ) as a step down, and a word becomes a mountain path whose peaks are those neighbouring pairs.

So row n slices the Catalan number by peak count. The article says each row adds up to the Catalan number, and that the triangle is symmetric: N(n, k) equals N(n, n-k+1). For n = 4 the row sums to 1 + 6 + 6 + 1 = 14. For n = 10 the row is 1, 45, 540, 2520, 5292, 5292, 2520, 540, 45, 1, and it adds up to 16,796, the tenth Catalan number.

Symmetry gives one more fact for free. If the row mirrors itself, its average k is exactly the middle of 1 and n, which is (n + 1) / 2. For n = 4 the weighted sum is 1 + 12 + 18 + 4 = 35, and 35 divided by 14 is 2.5. That argument is derived here, and the tool checks it in exact integers for every row you ask for.

Wikipedia gives a second form, (1/k) times (n-1 choose k-1) times (n choose k-1). For n = 8 and k = 5, the main form gives 56 x 70 / 8 = 490, and the second gives 35 x 70 / 5 = 490. The tool computes both for every k in the row and compares them.

Why only four are known to be prime

Wikipedia says four Motzkin primes are known: 2, 127, 15511 and 953467954114363. OEIS lists the same four terms under A092832. They sit at n = 2, 7, 12 and 36. The tool tests M(n) for every n from 2 to 400 and finds exactly those four, so no other Motzkin prime exists in that range.

The scan is cheap because most of the work is done at once. Of the 399 numbers from M(2) to M(400), 389 are divisible by a prime below 1000. Ten survive that sieve. Four are the known primes. The other six, n = 30, 37, 39, 116, 241 and 327, fail a Miller-Rabin round and are shown composite.

Miller-Rabin is a test that tries a base and looks for a witness of compositeness. Wikipedia explains that a composite number can still pass for some bases, so passing is only evidence. It also lists a fixed set of bases, the first twelve primes from 2 to 37, that decides every number below 2 to the power 64. All four known Motzkin primes are far below that bound, so the tool calls them prime. Above 2^64 the tool switches to a probable-prime test with twenty fixed bases and says so on the page. A probable prime is not a proof. In practice no Motzkin number up to M(400) above that bound passes, so the label never appears in this range.

Why are further Motzkin primes missing? I have no confirmed source that explains it, and the scan says only that none exists up to 400. The numbers grow about threefold per step, so each new candidate has more digits to find a factor.

What the tool cannot do

It does not cover generalised Motzkin numbers, Schroeder numbers or proofs, and it does not search for Motzkin primes beyond n = 400. It lists paths only up to n = 12, which is 15,511 of them, and Dyck words only up to n = 10, where the Catalan number is 16,796. Past those sizes you get the exact count but not the drawings.

The heavy arithmetic runs in a Web Worker, which MDN describes as a way to run a script in a background thread, so the page stays responsive. A calculation that takes more than 20 seconds is stopped, and nothing typed here leaves your device. To reproduce the example above, enter n = 10 and k = 5. The tool shows M(10) = 2,188 with its three routes, the row with N(10, 5) = 5,292, and the 2,188 paths and 5,292 Dyck words, each counted against its formula.

Sources

Every source consulted for this guide. Links checked November 10, 2026.

  1. Motzkin number - Wikipedia Wikipedia (CC BY-SA 4.0)
  2. Narayana number - Wikipedia Wikipedia (CC BY-SA 4.0)
  3. Theodore Motzkin - Wikipedia Wikipedia (CC BY-SA 4.0)
  4. Dyck language - Wikipedia Wikipedia (CC BY-SA 4.0)
  5. Catalan number - Wikipedia Wikipedia (CC BY-SA 4.0)
  6. A001006 - OEIS The On-Line Encyclopedia of Integer Sequences (CC BY-SA 4.0)
  7. A001263 - OEIS The On-Line Encyclopedia of Integer Sequences (CC BY-SA 4.0)
  8. A092832 - OEIS The On-Line Encyclopedia of Integer Sequences (CC BY-SA 4.0)
  9. Miller-Rabin primality test - Wikipedia Wikipedia (CC BY-SA 4.0)
  10. DLMF: 26.5 Lattice Paths: Catalan Numbers NIST Digital Library of Mathematical Functions (US government)
  11. BigInt - JavaScript | MDN MDN Web Docs (Creative Commons licence)
  12. Web Workers API - Web APIs | MDN MDN Web Docs (Creative Commons licence)