Tetrahedral number calculator
The 5th tetrahedral number is 35, the balls in a triangular pyramid five layers high. Enter a position from 1 to 378,076 and get its exact value from n(n+1)(n+2)/6, with no rounding at any step. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- N
- 5
- Tetrahedral
- 35
- Max n
- 378,076
The tetrahedral number calculator returns the n-th tetrahedral number for any positive integer index n. By definition that value is the sum of the first n triangular numbers, and it has the closed form n times n plus one times n plus two, all divided by six — the same quantity as the binomial coefficient choose n plus two, three. The first few terms are one, four, ten, twenty, thirty-five, fifty-six, eighty-four, one hundred twenty, one hundred sixty-five, and two hundred twenty. This capability is a pure parse engine: it multiplies and divides exact integers with BigInt, never approximates with floating-point roots, never samples randomness, never reads the clock, and never calls the network.
What a tetrahedral number is and how Te_n is defined
A tetrahedral number counts how many equal spheres you can stack in a triangular pyramid with n layers. The bottom layer is a triangular number T_n = n(n+1)/2, the layer above is T_(n-1), and so on down to a single sphere at the apex. Summing those layers gives the n-th tetrahedral number: Te_n equals the sum from k equals one to n of T_k.
That sum collapses to the compact formula Te_n = n(n+1)(n+2)/6, which is also the binomial coefficient C(n+2, 3). For n equals one the result is one; for two it is four; for three it is ten; for four it is twenty; for five it is thirty-five; for ten it is two hundred twenty.
The formula is exact for every positive integer n: among any three consecutive integers n, n+1, and n+2, at least one is divisible by two and at least one by three, so the product is always divisible by six and the result is a whole number. Valid positive indices always succeed with a deterministic tetrahedral value; there is no probabilistic path and no floating-point step that could round a near-miss.
How inputs are read and how the closed form stays exact
Optional leading plus signs are allowed; embedded spaces, hex prefixes, and exponential notation are rejected so a bad spreadsheet cell does not become a wrong pyramid count. Values below one are rejected with an explicit message: the tetrahedral sequence here starts at n equals one, matching the usual combinatorial and geometric definitions. Internally the product n times n plus one times n plus two is formed with BigInt, then divided by six, so intermediate products never lose low-order bits the way a double multiply might for large n.
Pair the output with triangular-number tables when you want to show the partial sums explicitly, or with binomial-coefficient tools when you prefer the C(n+2, 3) view of the same integer.
Where tetrahedral numbers fit in study, puzzles, and automation
Students meet tetrahedral numbers when learning figurate sequences, binomial coefficients, and three-dimensional stacking models after they already know triangular numbers. Teachers can generate answer keys for worksheets without trusting opaque calculator apps that hide floating-point division. Puzzle and game designers use tetrahedral counts for cannonball piles, tetrahedron resource costs, and level progression curves that grow as a cubic polynomial.
Developers use the same contract to validate sample data for number-theory libraries, to seed property tests that need known figurate values, or to pre-check that a configuration size matches a tetrahedral count before a simulation step that assumes stacked triangular layers. Contest practice often needs a fast offline source of Te_n so solutions can be checked without downloading OEIS tables or hard-coding long lists. Data pipelines that size batch jobs or pyramid-shaped caches sometimes need a closed-form item count from a depth parameter.
Pair it with square-number or Lucas tools when you need other classical sequences, and with combinatorial helpers when you need binomials beyond C(n+2, 3).
What you can do with it
Homework and figurate-number tables
Compute Te_n for worksheets and contest checks without hand-multiplying n(n+1)(n+2)/6 or trusting floating-point calculators.
Teaching stacked triangular layers
Show students how layer count n maps to a tetrahedral pile while they change inputs live in the browser at no cost.
FAQ
What does the tetrahedral number calculator cost?
It is free in your browser on this page.
What happens if n is below 1?
Tetrahedral numbers here are indexed from n equals 1 upward, so zero and negative indices are rejected.
How is Te_n computed?
The engine evaluates the closed form n(n+1)(n+2)/6 with exact BigInt arithmetic. No floating-point division is used, so the result is always a whole number for integer n.
What is the relationship to triangular numbers?
Te_n is the sum of the first n triangular numbers T_1 + T_2 + … + T_n, where T_k = k(k+1)/2. That sum equals n(n+1)(n+2)/6.
Is the algorithm randomized?
No. It uses deterministic integer multiplication and division. The same n always yields the same tetrahedral value.
Related tools
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/math/tetrahedral-number \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":5}'const res = await fetch("https://api.kit.forhosting.com/math/tetrahedral-number", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 5
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/tetrahedral-number",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 5
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/tetrahedral-number", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":5}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":5}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/tetrahedral-number", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"n": 5
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.tetrahedral_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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Indices below one are rejected with invalid_input because the classical tetrahedral sequence is indexed from one upward. Explore free in the browser for homework, contest prep, cannonball stacking puzzles, and teaching demos, or call the API at $0.002 per successful request when grading scripts and pipelines need reproducible figurate-number answers.
What a tetrahedral number is and how Te_n is defined
This capability returns that whole number as a safe JSON integer together with the index you supplied and a short formula string for documentation. Missing n, non-integers, fractions, scientific notation, values outside the supported range, and any index below one all fail with invalid_input and a clear message.
How inputs are read and how the closed form stays exact
The only required field is n, a positive integer index, with aliases index and k so forms and query strings can reuse one contract. Values above three hundred seventy-eight thousand seventy-six are rejected because Te_n would leave the safe integer range that JSON numbers and JavaScript Number can represent exactly.
Where tetrahedral numbers fit in study, puzzles, and automation
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result.
Integration use cases
Deterministic test fixtures
Generate reproducible tetrahedral values for unit tests, property checks, and CI assertions without embedding static OEIS tables.