ForHosting KIT · Math

Motzkin number calculator

Get the Motzkin number at any position n, built by the standard recurrence from two starting terms equal to 1: position 0 gives 1, and each later term adds the previous one to a sum of products of earlier terms. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
N
0
You get
Value
1

n-th Motzkin number via standard recurrence. Search intent: motzkin number calculator. No network calls or random seeds are required. Failed jobs are not billed.

How Motzkin numbers are built from the first two

Motzkin numbers form a sequence in which each term is built from the ones before it. The first two, at positions 0 and 1, are both 1. To get the term at position n, you start from the previous term and then add a sum of products: you pair up earlier terms whose positions add up to n minus 2, multiply each pair, and add all those products together. For position 2 there is only one pair, the term at position 0 with itself, so the result is 1 plus 1 times 1, which is 2. Every later term follows the same rule, so the terms are always whole numbers.

Using the calculator and avoiding slips

Type the position n, a whole number starting at 0, and the calculator returns the Motzkin number at that position next to the index you entered, so you can copy both into notes or a table. The usual slips when working by hand are counting positions from 1 instead of 0, forgetting to add the previous term before the sum of products, and pairing terms whose positions do not add up to n minus 2. A negative position or a value that is not a number is refused before any arithmetic, and the same position always gives the same answer, with no randomness involved.

Teaching

Pinned goldens.

What is the first Motzkin number?

Positions start at 0, and the first two terms, at positions 0 and 1, are both 1. Every other number in the sequence is built from those two starting values.

How is each Motzkin number calculated?

Take the previous term and add the products of every pair of earlier terms whose positions add up to n minus 2. For position 2 that gives 1 plus 1 times 1, which is 2.

Which values of n can I enter?

Whole numbers from 0 upward. A negative position or something that is not a number is refused before any arithmetic, instead of producing a result that means nothing.

Will I always get the same result?

Yes. The calculation uses no randomness and no network connection, so the same position always gives the same answer. The position you entered is shown next to the result as well.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/math/motzkin-number

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/math/motzkin-number \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":5}'
{
  "n": 5
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.motzkin_number",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos.

How it works

n-th Motzkin number via standard recurrence. No network calls or random seeds are required. Failed jobs are not billed. No network calls or random seeds are required. Failed jobs are not billed. M0=M1=1; Mn=M(n-1)+Σ Mi M(n-2-i). The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos.

Inputs, limits and rounding

Optional decimals use half-up once. Outputs echo inputs. No network calls or random seeds are required. Failed jobs are not billed. No network calls or random seeds are required. Failed jobs are not billed. Provide required JSON fields. Invalid types raise invalid_input. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos.

When to use it

Use when search intent matches. n-th Motzkin number via standard recurrence. No network calls or random seeds are required. Failed jobs are not billed. No network calls or random seeds are required. Failed jobs are not billed. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos.

Quick check

Free widget.

Automation

Same JSON via API.

Free?

Yes tier A.

Network?

No.

Bad input?

invalid_input.

API?

Yes.

Locales?

EN-only; Nitro hydrates.

Read the full KIT documentation →