Sum of first n even numbers
Add 2 + 4 + … + 2n in one step with the formula n(n + 1): with n of 5 the total is 30, and the result stays an exact whole number for any n up to ten million. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Positive integer n
- 5
- Value
- 30
- Sum
- 30
The sum of the first n even numbers is a classic closed form that every pre-algebra and discrete-mathematics student meets early: two plus four plus six and so on up to two-n equals n times n plus one. That identity turns a loop over even terms into a single quadratic polynomial that is always exact for positive integer n. This calculator evaluates the formula with deterministic integer arithmetic for any accepted positive index, rejects n below one with a clear validation error, and returns both the numeric sum and the formula string so homework checkers, scripts, and lesson pages can trust a single contract.
The formula for the sum of the first n even numbers
By definition the sum of the first n even numbers is S(n) equals two plus four plus six continuing through two times n. Factoring two out of each term produces S(n) equals two times the sum of the first n positive integers, and that triangular sum is n times n plus one over two, so the twos cancel and the compact closed form is simply S(n) equals n times the quantity n plus one.
Substituting small positive integers recovers the familiar table: S(1) is two, S(2) is six, S(3) is twelve, S(4) is twenty, S(5) is thirty, S(6) is forty-two, S(7) is fifty-six, S(8) is seventy-two, S(9) is ninety, and S(10) is one hundred ten. Algebra courses use this identity when they introduce arithmetic series and even-term patterns, discrete-mathematics courses use it for counting arguments and parity exercises, and programming contests use it whenever a solution needs a constant-time sum of even numbers instead of an O(n) loop.
Understanding that the result is a quadratic polynomial in n, not a recurrence you must iterate from one, is the first step to using the formula confidently in code, on paper, and in teaching materials that explain why two plus four through two-n collapses so cleanly.
Practical use, limits, pricing, and delivery
Use the browser tool when you want an immediate sum of even numbers while studying arithmetic series, checking a contest answer, or explaining the n(n+1) identity without installing a computer-algebra system. Accepted indexes run from one through ten million so classroom demos, large teaching tables, and Project-Euler-scale checks remain feasible without unbounded memory growth. Results are fully deterministic: the same n always yields the same sum and the same value echo.
There is no language model, no external arithmetic service, and no randomness, so the capability is safe to pin in continuous-integration checks and reproducible lesson materials.
What you can do with it
Homework and contest verification
Students and graders confirm 2+4+…+2n for a given n without a local computer-algebra system or hand-written loops.
Arithmetic series lesson demos
Lesson pages that introduce even-term series can show n(n+1) beside worked values for small positive n.
Scripts and CI oracles
Automated checkers and interview sandboxes call a deterministic closed form instead of reimplementing the sum of even numbers in every language.
FAQ
What is the formula for 2 + 4 + … + 2n?
The standard closed form is n(n+1). This calculator evaluates that polynomial with exact integer arithmetic.
What happens if n is below 1?
Only positive integers n ≥ 1 are accepted and validation failures are not charged.
Is the sum of first n even numbers calculator free?
The browser tool runs free on your device.
Why use the closed form instead of looping over even terms?
The polynomial is exact for integer n and runs in constant time after validation. This calculator evaluates it with BigInt so large indexes stay precise without summing millions of terms.
Is n the number of even terms or the last even number?
The number of terms. With n equal to 10 you add ten even numbers, from 2 up to 20, so the last term is always twice n, and the total is 110.
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/sum-of-even \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":5}'const res = await fetch("https://api.kit.forhosting.com/math/sum-of-even", {
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/sum-of-even",
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/sum-of-even", 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/sum-of-even", 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.sum_of_even",
"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.
Limits
max_n | 10000000 |
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
How this calculator validates n and evaluates the closed form
The engine checks that n is present as a finite integer, is at least one, and stays within the published upper bound of ten million, then returns sum equal to n times n-plus-one, together with the formula string for documentation and a value field that echoes the same result so callers who prefer a generic name see both labels. There is no loop over even terms on the hot path: the closed form is constant time after validation. Send a JSON body with the required integer field n. Values of n below one fail immediately with invalid_input and are not charged; the same error path covers missing n, non-integers, non-finite numbers, and values above the published maximum. Arithmetic uses BigInt so intermediate products never lose low-order bits, and when the final result fits inside the safe JSON integer range it is returned as a number rather than a decimal string.
Practical use, limits, pricing, and delivery
Each successful request is one billable item at $0.002; failed validation does not consume balance. Wire the endpoint into algebra demos, coding-interview sandboxes, discrete-math tutorials, or integer preprocessing steps where you already prefer exact closed-form arithmetic over approximate heuristics or opaque black-box calculators that cannot show the formula or the definition as two plus four up through two-n.
Technical questions
How do I compute the sum of the first n even numbers with this API?
Send a JSON body with positive integer field n to math.sum_of_even. The response returns sum = n*(n+1), the formula string, and value (same as sum).