ForHosting KIT · Math

Sum of First n Natural Numbers Calculator

1 + 2 + … + 100 is 5,050: the formula n(n + 1)/2 gives the total of the first n natural numbers at once, without adding each one. Enter how many numbers to include and get the exact sum. 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
100
You get
Total
5,050

The sum of the first n natural numbers appears everywhere from introductory algebra and spreadsheet checks to counting problems and software estimates. Instead of adding every integer one by one, this calculator applies the closed-form triangular formula n times n plus one, divided by two. Enter any supported positive integer and receive the exact total, the validated count, and the formula used. Non-positive counts, fractions, missing values, and unsupported inputs are rejected clearly. The calculation is deterministic, uses exact integer arithmetic, and performs no network calls, random choices, or time-dependent operations, making it suitable for lessons, automated tests, and repeatable production workflows.

Understanding the triangular-number formula

The first n natural numbers are the consecutive integers beginning with one and ending with n. Their sum can be written as 1 + 2 + 3 + ... + n. The closed form is n(n+1)/2, which is also the formula for the nth triangular number.

One useful way to understand it is to write the sequence forward and backward. The first and last terms make n+1, the second and next-to-last terms also make n+1, and that pairing continues across n terms. Two copies of the original sum therefore equal n(n+1), so one copy equals half that product.

The calculator reports the formula alongside the total so the result is useful not only as an answer, but also as a transparent step in homework, teaching material, documentation, or a program that needs to record how the value was obtained.

Entering n and interpreting the result

Provide n as a positive whole number. It represents how many natural numbers are included, not the value of an arbitrary first term or the number of gaps between terms. When n is 100, the range is 1 through 100 and the returned total is 5,050.

The response includes n, total, and the formula string n*(n+1)/2. If a supported input ever produces a value beyond that safe range, the same exact integer is represented as a decimal string so no digits are silently rounded. Validation deliberately rejects zero and negative values because this capability defines a non-empty count of natural numbers.

It also rejects fractions, nonnumeric text, missing n, and values above the published limit.

When a closed-form sum is the right tool

Typical examples include counting handshakes in a staged construction, checking the total number of items added over steadily increasing rounds, validating triangular arrangements, and replacing an unnecessary accumulation loop in code. The formula takes a constant number of arithmetic operations rather than visiting all n terms, so its intent stays clear even for a large count. This capability is narrower than a general arithmetic-series calculator: the first term is always one, the common difference is always one, and n must be positive.

The implementation does not contact an external mathematics service and does not use a language model.

Check algebra homework

Verify a triangular-number result and show the exact n(n+1)/2 formula used to obtain it.

Replace an accumulation loop

Compute a consecutive total in constant time when application code would otherwise add every integer from one through n.

Validate growing-round totals

Find the cumulative number of items when round one adds one item, round two adds two, and each later round adds one more.

What is the sum of the first n natural numbers?

It is n(n+1)/2. The calculator evaluates this triangular-number formula exactly for a supported positive integer n.

Does the sequence start at zero or one?

It sums 1 through n. Including zero would not change the total, but n is defined here as a positive count and must be greater than zero.

Why are zero and negative values rejected?

This capability accepts only a non-empty count of the first natural numbers.

Why does the formula n(n + 1)/2 work?

Write the sum forwards and backwards, one under the other. Each pair adds up to n + 1 and there are n pairs, so two copies of the sum equal n(n + 1) and one copy is half of that.

Can I add a range that does not start at 1?

No. This calculator always adds every consecutive whole number from 1 up to n. For a different starting value or step size, a general arithmetic series is the right tool.

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

max_n100000000
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.

Understanding the triangular-number formula

For n=5, the calculation is 5 times 6 divided by 2, giving 15, which matches 1+2+3+4+5. This reasoning works for every positive integer count.

Entering n and interpreting the result

For totals that fit safely in ordinary JSON integer precision, total is a number. A numeric string containing a positive integer is accepted by the shared solver, which helps the text-oriented browser input behave consistently with structured API calls. These rules keep the output unambiguous and prevent a malformed count from looking like a legitimate triangular number.

When a closed-form sum is the right tool

Use this calculator whenever a task asks for the total of every consecutive positive integer from one through a known endpoint. That narrow contract makes integration simple and guards against confusing the count with a custom endpoint or step size. Browser use is free, while each successful API item costs $0.002.

Is the calculation exact for large supported values?

Yes. The solver uses integer arithmetic and returns a decimal string instead of an unsafe JSON number if that is needed to preserve every digit.

What does the API cost?

Each successful API item costs $0.002. You can also run the calculator free in your browser.

Read the full KIT documentation →