ForHosting KIT · Math

Sum of first n cubes

Add up 1³ + 2³ + … + n³ exactly for any whole number n: the first 10 cubes sum to 3025, which is 55 squared, the square of the 10th triangular number. 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
10
You get
Sum
3,025
Triangular
55
Max n
13,776

The sum of the first n cubes calculator returns the exact value of one cubed plus two cubed plus every cube up to n cubed for any non-negative integer n. By Nicomachus's theorem that sum always equals the square of the n-th triangular number: n times n plus one, divided by two, then squared. The first few results are zero for n equals zero, one for n equals one, nine for n equals two, thirty-six for n equals three, one hundred for n equals four, two hundred twenty-five for n equals five, and three thousand twenty-five for n equals ten. This capability is a pure parse engine: it multiplies and divides exact integers with BigInt, never approximates with floating-point powers, never samples randomness, never reads the clock, and never calls the network.

What the sum of the first n cubes is and why it equals a square

The sum of the first n positive cubes is the partial sum one cubed plus two cubed plus three cubed and so on through n cubed. A remarkable classical identity, often named after Nicomachus, states that this sum is always a perfect square: specifically, it equals the square of the n-th triangular number T_n equals n times n plus one over two.

For n equals one the sum is one and the triangular number is one; for two the cubes add to nine and T_2 is three; for three the cubes add to thirty-six and T_3 is six; for five the cubes add to two hundred twenty-five and T_5 is fifteen; for ten the cubes add to three thousand twenty-five and T_10 is fifty-five. The identity holds for every non-negative integer, including the empty sum at n equals zero, which is zero.

You receive the index n, the sum of cubes, the triangular number that was squared, a short formula string for documentation, and the supported maximum index. Valid non-negative indices always succeed with a deterministic sum; 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 sum. Negative values are rejected with an explicit message: the sum of the first n cubes here requires n greater than or equal to zero, matching the usual combinatorial definition of the partial sum.

Internally the product n times n plus one is formed with BigInt, halved to obtain the triangular number, then squared, so intermediate products never lose precision the way a double multiply-and-pow path might for large n. Pair the output with triangular-number tables when you want to show T_n before it is squared, or with square-number tools when you prefer to verify that the result is a perfect square independently.

Where cube sums fit in study, contests, and automation

Students meet the sum of cubes when learning figurate numbers, induction proofs, and the relationship between triangular numbers and squares. Teachers can generate answer keys for worksheets without trusting opaque calculator apps that hide floating-point exponentiation or that silently convert large integers to scientific notation. Contest practice often needs a fast offline source of 1³ plus through n cubed so solutions can be checked without downloading OEIS tables or hard-coding long lists.

Puzzle and game designers use cube-sum growth curves for resource costs and level progression that grow as a fourth-degree polynomial in n. Developers use the same contract to validate sample data for number-theory libraries, to seed property tests that need known Nicomachus values, or to pre-check that a batch size matches a closed-form cube sum before a simulation step. Data pipelines that size pyramid-shaped caches or stacked resource budgets sometimes need a closed-form item count from a depth parameter that maps to cubes rather than linear layers.

Pair it with tetrahedral-number or square-number tools when you need related figurate sequences, and with geometric-sequence helpers when you need other classical closed forms.

Homework and Nicomachus identity checks

Compute 1³+…+n³ for worksheets and contest checks without hand-squaring T_n or trusting floating-point power calculators.

Teaching triangular squares

Show students how n maps to T_n squared while they change inputs live in the browser at no cost.

What does the sum of first n cubes calculator cost?

It is free in your browser on this page.

What happens if n is negative?

The sum of the first n cubes is defined here for n greater than or equal to zero, so negative indices are rejected.

How is the sum computed?

The engine evaluates the closed form (n(n+1)/2)² with exact BigInt arithmetic. No floating-point powers or loops over cubes are used, so the result is always a whole number for integer n.

What is the relationship to triangular numbers?

The n-th triangular number is T_n = n(n+1)/2. Nicomachus's theorem states that 1³+2³+…+n³ equals T_n squared. The response includes both the sum and the triangular value that was squared.

Is the algorithm randomized?

No. It uses deterministic integer multiplication and division. The same n always yields the same sum value.

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/sum-of-cubes

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/sum-of-cubes \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":10}'
{
  "n": 10
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.sum_of_cubes",
  "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.

Negative indices are rejected with invalid_input because the classical partial sum is defined for n greater than or equal to zero. Explore free in the browser for homework, contest prep, number-theory demos, and teaching Nicomachus's identity, or call the API at $0.002 per successful request when grading scripts and pipelines need reproducible cube-sum answers.

What the sum of the first n cubes is and why it equals a square

This capability evaluates the closed form with exact integer arithmetic rather than looping over cubes or taking floating-point roots, so intermediate products never lose low-order bits and the JSON result is always a whole number. Missing n, non-integers, fractions, scientific notation, values outside the supported range, and any negative index 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 non-negative integer upper bound, with aliases count and k so forms and query strings can reuse one contract. Values above thirteen thousand seven hundred seventy-six are rejected because the squared triangular number would leave the safe integer range that JSON numbers and JavaScript Number can represent exactly.

Where cube sums fit in study, contests, 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.

Deterministic test fixtures

Generate reproducible sum-of-cubes values for unit tests, property checks, and CI assertions without embedding static OEIS tables.

Read the full KIT documentation →