Motzkin Number Calculator

Input

Motzkin number M(5)21
Previous value M(4)9
Growth ratio M(5) / M(4)2.33
Next value M(6)51
How this was calculated
  1. Motzkin numbers count the ways to draw non-crossing chords between points on a circle, allowing some points to stay unmatched.
  2. They obey the recurrence M(n) = M(n-1) plus the sum of M(k) x M(n-2-k) for k from 0 to n-2, starting from M(0) = M(1) = 1.
  3. Building the sequence up gives M(4) = 9 and M(5) = 21.
  4. The sequence grows by a factor approaching 3: M(5) / M(4) is 2.33 here, and the next value is M(6) = 51.

The Motzkin Number Calculator computes the nth Motzkin number for the value of n you enter. Motzkin numbers count Motzkin paths and, equivalently, the ways to draw non-crossing chords between points on a circle when some points may stay unmatched. The sequence begins 1, 1, 2, 4, 9, 21, so the fifth Motzkin number is 21. Larger terms grow quickly: M(8) = 323, M(9) = 835, and M(10) = 2,188. The calculator gives you the exact value for your chosen n, so you can check a single term or follow the sequence from the start.

The method behind the calculator is the standard Motzkin recurrence: M(n) = M(n-1) plus the sum of M(k) x M(n-2-k), starting from M(0) = M(1) = 1. This recurrence is the accepted way to generate Motzkin numbers because it builds each term directly from the earlier terms it depends on, which is why the results match the sequence 1, 1, 2, 4, 9, 21 and the later values such as M(8) = 323 and M(10) = 2,188. It also explains the growth: the ratio M(n) / M(n-1) approaches 3, and at n = 10 it is 2.62. This page shows the formula, step-by-step workings, worked examples and sources so you can follow how every result is produced.

Worked examples

Five steps

(5 steps)

Motzkin number M(5)21
Previous value M(4)9
Growth ratio M(5) / M(4)2.33
Next value M(6)51

Eight steps

(8 steps)

Motzkin number M(8)323
Previous value M(7)127
Growth ratio M(8) / M(7)2.54
Next value M(9)835

Ten steps

(10 steps)

Motzkin number M(10)2,188
Previous value M(9)835
Growth ratio M(10) / M(9)2.62
Next value M(11)5,798

What Motzkin numbers count

A Motzkin path is a walk on a grid that starts on the horizontal axis and ends on it, using only three kinds of steps: an up step, a down step, and a flat step that moves sideways without changing height. The one rule that makes these paths special is that the walk may touch the axis but never dip below it. Count all the distinct paths of a given length that obey that rule, and you have the Motzkin numbers. This is the picture to keep in mind when you use a motzkin number calculator: each result is the size of a family of such paths, not an arbitrary figure pulled from a table.

The same numbers answer a second, more visual question. Place points on a circle and connect pairs of them with chords so that no two chords cross. If every point had to be paired, you would be counting a different family of objects. Motzkin numbers count the more forgiving case: some points may stay unmatched, and only the matched pairs are joined by chords. Each chord arrangement of this kind corresponds to exactly one Motzkin path, which is why the two descriptions produce the same sequence. The flat step is the unmatched point, the up and down steps are the two ends of a chord, and the no-dipping rule mirrors the no-crossing rule.

The sequence itself is easy to recognize once you have seen it. It begins 1, 1, 2, 4, 9, 21, so the fifth Motzkin number is 21. It keeps climbing quickly: M(8) = 323, M(9) = 835, and M(10) = 2,188. Those values give a feel for how fast the counts grow, and they are a useful check when you want to confirm that a tool is returning the right family of numbers.

The growth is regular rather than wild. Each Motzkin number is built from the ones before it: M(n) equals M(n-1) plus the sum of M(k) times M(n-2-k), starting from M(0) = M(1) = 1. That recurrence is why the ratio M(n) / M(n-1) creeps toward 3 as n rises. At n = 10 the ratio is 2.62, still short of the limit but clearly heading that way. Knowing the recurrence also explains why the numbers are so easy to generate in order and so awkward to guess from a single term.

Two views, one sequence: Motzkin paths that never dip below the axis, and non-crossing chord diagrams on a circle where some points may stay unmatched. Both are counted by the same numbers — 1, 1, 2, 4, 9, 21, and onward.

Building the sequence by recurrence

The recurrence is the engine behind every value the calculator returns. It states that M(n) equals M(n-1) plus the sum of M(k) × M(n-2-k), starting from M(0) = M(1) = 1. In plain terms, each new Motzkin number is built from the one just before it plus a collection of products of earlier Motzkin numbers. Nothing is guessed and nothing is looked up from a hidden list — the sequence is assembled one step at a time, which is exactly what a motzkin number calculator does when you ask it for a term.

Watch the first few steps. With M(0) = 1 and M(1) = 1, the recurrence produces M(2) = 2, then M(3) = 4, then M(4) = 9. The sequence begins 1, 1, 2, 4, 9, 21, so the fifth Motzkin number is 21. That value of 21 is not a special case; it is what falls out when the earlier terms are combined by the rule. Each term depends only on terms already computed, so the table below can be read strictly from top to bottom.

The same process carries on past the small cases. Continuing the recurrence gives M(8) = 323, and it also gives M(9) = 835 and M(10) = 2,188. Those later values are worth checking against intuition: the numbers climb quickly, but not explosively at first. The growth ratio M(n) / M(n-1) approaches 3, and at n = 10 it is 2.62 — a useful reminder that the long-run tendency toward 3 is approached gradually rather than reached at small n.

Because every term is defined by earlier terms, the recurrence also explains why the sequence is tied to counting problems. The Motzkin numbers count Motzkin paths and, equivalently, the ways to draw non-crossing chords between points on a circle when some points may stay unmatched. The recurrence mirrors that structure: the single M(n-1) piece and the summed products of pairs of earlier values correspond to building a larger configuration from smaller ones. The table below shows the sequence as the recurrence builds it, with the highlighted terms matching the values discussed above.

nM(n)
01
11
22
34
49
521
8323
9835
102188
M(0) = 1, M(1) = 1, and M(n) = M(n-1) + the sum of M(k) × M(n-2-k). The fifth Motzkin number is 21; M(8) = 323; M(10) = 2,188.

Motzkin versus Catalan

Catalan numbers and Motzkin numbers are close cousins, and the difference between them is easy to state: Catalan numbers force every point to be matched, while Motzkin numbers allow some points to stay unmatched. Both families count ways to draw non-crossing chords between points on a circle, but the Catalan count applies only when every point gets a chord. Relax that rule so points may sit out, and you are counting Motzkin paths instead. A motzkin number calculator is useful precisely because this small change in the rules produces a different, and in some ways gentler, sequence.

The shared ancestry shows up in how the numbers are built. The Motzkin numbers follow the recurrence M(n) = M(n-1) plus the sum of M(k) x M(n-2-k), starting from M(0) = M(1) = 1. That first term, M(n-1), is the piece with no direct Catalan counterpart in the same form: it accounts for the option of leaving a point unmatched, which is exactly the freedom Catalan numbers do not grant. The summed term handles the matched pairs, splitting a path into two smaller Motzkin paths. Because one term simply carries the previous value forward, Motzkin numbers grow more slowly step by step than Catalan numbers do.

You can see the slower pace in the early sequence, which begins 1, 1, 2, 4, 9, 21: the fifth Motzkin number is 21. Further along, M(8) = 323 and M(10) = 2,188, with M(9) = 835 in between. Those values climb steadily without the explosive jumps that matched-everything counting produces. The growth ratio M(n) / M(n-1) approaches 3, but it gets there gradually; at n = 10 it is 2.62. So each additional point multiplies the count by something a bit under three, and the multiplier creeps upward toward 3 as n increases.

That approach to a factor of 3 is the family resemblance in numeric form. Catalan-style counting, with no unmatched points permitted, multiplies by a larger factor per step. Motzkin counting keeps the same non-crossing, chord-drawing structure but pays a smaller price for each new point, because that point may simply remain alone. The result is a sequence that grows more slowly per step yet by a factor approaching 3 — a steady, predictable climb rather than a surge.

When you compare the two families side by side, keep the rule difference in mind: matched-only versus matched-or-unmatched. The recurrence, the sample values, and the ratio all follow from that single allowance for unmatched points.

  • Catalan numbers: every point must be matched with a non-crossing chord.
  • Motzkin numbers: points may stay unmatched, which is why the count grows more slowly per step.
  • Motzkin recurrence: M(n) = M(n-1) plus the sum of M(k) x M(n-2-k), with M(0) = M(1) = 1.
  • Early values: 1, 1, 2, 4, 9, 21 — the fifth Motzkin number is 21.
  • Later values: M(8) = 323, M(9) = 835, M(10) = 2,188.
  • Growth ratio M(n) / M(n-1) approaches 3; at n = 10 it is 2.62.
The one rule that separates the families: Catalan counting matches every point, Motzkin counting lets some points stay unmatched — so the Motzkin ratio per step approaches 3, reaching 2.62 at n = 10.

Where they appear

Motzkin numbers show up wherever you are counting arrangements that allow some elements to sit out. The classic picture is a Motzkin path: a walk that starts at zero, ends at zero, and at each step either rises by one, falls by one, or stays level, never dipping below the starting line. The same numbers also count the ways to draw non-crossing chords between points on a circle when some points may stay unmatched. That single rule — match some, leave others alone — is why these numbers reach into so many different counting problems. A motzkin number calculator lets you check these counts for a given n without working through the recurrence by hand.

In combinatorics, Motzkin numbers are a standard enumeration sequence, sitting alongside the Catalan and Fibonacci numbers as one of the counts that turns up again and again. The sequence begins 1, 1, 2, 4, 9, 21: the fifth Motzkin number is 21. The values grow quickly but not explosively. M(8) = 323 and M(10) = 2,188, with M(9) = 835 in between. The growth ratio M(n) / M(n-1) approaches 3, and at n = 10 it is 2.62 — still climbing toward that limit. Each term follows the recurrence M(n) = M(n-1) plus the sum of M(k) x M(n-2-k), starting from M(0) = M(1) = 1, which is exactly the kind of split-and-recombine structure that shows up when you break a problem into a first piece and the rest.

RNA secondary structure counting is one of the most cited applications. When an RNA strand folds, its bases pair up, but not every base has to find a partner, and the pairings cannot cross. That is the same rule as drawing non-crossing chords on a circle with some points left unmatched — so the number of possible structures follows the Motzkin numbers. The unmatched points represent bases that stay unpaired, and the pairing pattern represents the bonds that form. Researchers use these counts to gauge how many foldings are even possible for a strand of a given length, which is a first step before asking which foldings are likely or stable.

Lattice path problems are the third common home. A Motzkin path is a lattice walk with three move types — up, down, and level — and counting such walks between two points is a direct use of the sequence. Variants appear when you add restrictions, such as staying above the axis or limiting the number of level steps, and the same recurrence structure carries over. Because the level step is what separates Motzkin paths from the simpler two-move walks, these counts appear in models where a system can pause or hold steady at each stage.

Across all three settings, the shared feature is choice: each position can pair with something, pair back, or remain alone. That is the thread that ties chords on a circle, RNA foldings, and lattice walks to one sequence.

The fifth Motzkin number is 21, and the ratio M(n) / M(n-1) approaches 3 — at n = 10 it is 2.62.

FAQs

What is a Motzkin number?

A Motzkin number counts the Motzkin paths of a given length n. These are paths made of up steps, down steps and level steps that never drop below ground level and finish back at ground level. So the Motzkin number for length n tells you how many such paths exist.

What is M(5)?

M(5) is 21. The Motzkin sequence begins 1, 1, 2, 4, 9, 21, 51, 127, 323, so the term at n = 5 is 21. Counting from n = 0, that is the sixth entry in the list, and it follows M(4) = 9.

How fast do Motzkin numbers grow?

Each Motzkin number is a little under three times the previous one, because the ratio between consecutive terms approaches 3 as n increases. The approach is gradual rather than instant: at n = 10 the ratio is 2.62, still noticeably below the limiting value of 3.

How do Motzkin and Catalan numbers differ?

Both families count paths that stay at or above ground and end at ground level, but the rules differ. Catalan paths have no flat steps, and every point is matched. Motzkin paths allow flat steps, and they also allow unmatched points, which makes them the more permissive of the two.

What is M(10)?

M(10) is 2,188. It follows M(9) = 835, so the step from n = 9 to n = 10 multiplies the count by a factor a little above 2.6. The value 2,188 is the eleventh term in the sequence, counting from M(0) = 1.

Who were they named for?

The Motzkin numbers and Motzkin paths are named for Theodore Motzkin, the mathematician whose name the sequence and the paths carry. The naming credits him rather than describing a property of the numbers themselves, which count paths with up, down and level steps.

Sources

Related calculators

Catalan Number Calculator
The Catalan numbers — C(2n, n) divided by (n + 1) — counting bracketings, binary trees, polygon triangulations and lattice paths that never cross the diagonal.
Fibonacci Calculator
The nth Fibonacci number, computed exactly with arbitrary-precision arithmetic — plus the next term, the sum of the first n terms, and how close the ratio has come to the golden ratio.
Lucas Number Calculator
The nth Lucas number by its recurrence, with the companion Fibonacci number, the identity check L(n) = F(n-1) + F(n+1) and the ratio that converges to the square root of five.