ForHosting KIT · Math

Sum of first n odd numbers calculator

1 + 3 + 5 + 7 + 9 adds up to 25: the first n odd numbers always total exactly n squared. Enter n and get the sum along with the last odd number in the list, here 9. 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
5
You get
Sum
25
Last odd
9
Identity
1+3+...+(2n-1)=n^2

The sequence of the first n positive odd numbers is one of the cleanest bridges between counting and perfect squares in elementary algebra. Add one, then three, then five, and continue through the n-th odd term, and the running total is always exactly n squared—not approximately, not after rounding, but identically for every positive integer n. This calculator accepts a positive integer count, rejects zero and negative values with a clear validation error, and returns the closed-form total together with the last odd term and a short identity string you can show next to the answer.

Why the first n odd numbers add up to n squared

List the first n positive odd numbers as one, three, five, and so on through two n minus one. There are exactly n terms, and the k-th term (starting at k equals one) is two k minus one.

Adding small cases by hand already reveals the pattern: for n equals one the sum is one, which is one squared; for n equals two the sum is four, which is two squared; for n equals three the sum is nine; for n equals four the sum is sixteen; for n equals five the sum is twenty-five.

Mathematical induction turns the pattern into a theorem: assume the sum of the first k odds equals k squared; the next odd number is two k plus one; adding it yields k squared plus two k plus one, which factors as open parenthesis k plus one close parenthesis squared. A geometric story matches the algebra: an n by n square of unit cells can be built by nesting L-shaped borders whose successive lengths are the successive odd numbers, so the area after n borders is n squared.

After validating that n is an integer at least one and within the supported upper bound, it multiplies n by n, which is exact for every integer in range and free of floating-point drift. Classroom spot checks include n equals ten giving one hundred, n equals twenty giving four hundred, and n equals one hundred giving ten thousand.

A careful loop that accumulates two i plus one from zero through n minus one produces the same total, so the closed form is a trustworthy oracle for auto-graders and coding drills that ask students to rediscover the identity with loops or induction.

Homework and exam checks

Verify that 1+3+…+(2n−1) equals n² for classroom problems and reject n below 1 with a clear error instead of a wrong total.

Teaching induction with live numbers

Show students how each new odd term grows the running total to the next perfect square, using the same function in browser demos and grading scripts.

What formula does this calculator use?

The sum of the first n positive odd numbers is n²: 1 + 3 + … + (2n − 1) = n² for every integer n ≥ 1.

What happens if n is 0 or negative?

The first n odd positives are only defined for n at least 1.

What does it cost?

The browser tool is free and runs locally.

Why is the sum of the first n odd numbers n squared?

Picture an n by n square built from nested L-shaped borders: their lengths are 1, 3, 5 and so on. After n borders the area is n squared, and induction proves the same result algebraically.

What is the last odd number added?

It is 2n − 1. For n of 5 the last odd number is 9, so the list is 1, 3, 5, 7 and 9, and the sum is 25.

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/algebra/sum-of-odd-numbers

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/algebra/sum-of-odd-numbers \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":5}'
{
  "n": 5
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "algebra.sum_of_odd_numbers",
  "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.

Because the free browser path and the paid API share one module, classroom demos and production pipelines never silently disagree on the same n.

Why the first n odd numbers add up to n squared

This endpoint does not re-prove the theorem on every call.

Input contract, response fields, and validation errors

The value must be an integer between one and ten million inclusive. Use the free browser tool for quick sanity checks, then call the identical contract from scripts when you need bulk evaluation of odd-number sums without reimplementing the gate in every language. Keep expected goldens pinned to the closed form so refactors of the implementation never change the public numbers. Send one required integer field named n, with optional aliases count, terms, and how_many for friendlier forms. Missing fields, empty strings, decimals, non-numeric text, zero, and negative numbers fail with invalid_input and are not charged. On success the JSON body echoes the normalized n, returns sum as n squared, includes last_odd as two n minus one so clients can label the final term without recomputing it, sets formula to the compact string n caret two, and sets identity to a readable string describing one plus three plus ellipsis plus open parenthesis two n minus one close parenthesis equals n squared. Worked examples: n equals five yields sum twenty-five and last_odd nine; n equals one yields sum one and last_odd one; n equals seven yields sum forty-nine and last_odd thirteen; n equals twelve yields sum one hundred forty-four and last_odd twenty-three. Requests with n equals zero or n equals negative three both fail invalid_input with a message that n must be at least one.

Where this identity earns its keep in practice

Middle-school and secondary algebra units constantly ask students to sum the first n odd numbers or to explain why that total is a perfect square. A trusted calculator with a strict n greater than or equal to one check speeds homework grading and removes spreadsheet mistakes where someone multiplies the wrong closed form or off-by-one the last term. If you later need the sum of the first n even numbers, an arbitrary arithmetic series, or odd numbers starting at an offset other than one, treat those as separate search intents and separate tools rather than overloading this landing page with extra parameters that dilute the SEO promise of a first-n odds calculator. Programming contest warm-ups and coding interview drills use the same identity as a first exercise in loops, induction, or closed-form thinking, so an API oracle that returns sum, last_odd, and the formula string lets auto-graders compare student output without flaky numeric tolerance. Visualization and teaching demos that grow an n by n grid one L-shaped odd border at a time can pull last_odd and sum on each step so narration and numbers stay aligned. Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.

Coding drills and auto-graders

Compare student loop implementations against the closed-form sum and last_odd without re-deriving the identity in every test harness.

What is last_odd in the response?

It is the n-th positive odd number, equal to 2n − 1, so you can display the final term without recomputing it.

Does this sum even numbers or an arbitrary odd range?

No. This endpoint only sums the first n positive odds starting at 1. Other series are separate tools.

Read the full KIT documentation →