Sum of Integers Calculator
Add every integer in an inclusive range with the closed form, exactly, including negative bounds.
Sum of Integers Calculator
Add every integer in an inclusive range with the closed form, exactly, including negative bounds.
What the page prints, and what it refuses
Every figure is printed with the rule or formula that produced it, and any numerical tolerance is stated on the result rather than implied. The page refuses an input the formula does not define and names the value it read; it prints no answer it cannot support.
The calculation runs entirely in this browser tab; nothing is uploaded.
The page adds every whole number in an inclusive range without looping over them. From 1 to 100 the sum is 5050, from the closed form (1 + 100) × 100 ÷ 2.
The range may start below zero: from −3 to 4 the seven integers sum to 4. Both bounds and the count are printed, so the formula can be checked against the range you typed.
Why the closed form is exact
Pair the first and last terms: each pair sums to from + to, and there are count ÷ 2 pairs. That gives sum = (from + to) × count ÷ 2, where count = to − from + 1.
When the count is odd the product is even, so the division is exact rather than an average. The page uses BigInt, so a range up to 10^15 is exact and prints every digit.
How to use Sum of Integers Calculator
Enter the first and last integers, smaller first, then press Run.
The result prints the sum, the range, the count and the closed form with your bounds substituted.
What to Expect
Best for
- Adding a long consecutive range exactly
- Checking a series formula by hand
- Summing a range that crosses zero
Not ideal for
- A non-consecutive list of numbers, which needs a column sum
- Ranges above 100,000,000 integers
- Bounds beyond 10^15, where exactness would need a bigger promise
What this tool keeps
- Both bounds exactly, including their signs
What may need cleanup
- Nothing: the sum is a final integer
Common errors
- A backwards range is refused
- A bound beyond 10^15 is refused with the limit named
Example use cases
- Add 1 to 100
- Add −3 to 4
- Check the sum of the first n integers
Sample input
from = 1, to = 100
Sample output
5050, from (1 + 100) × 100 ÷ 2
Who this is for
- Students checking a series
- Readers adding a long range
Frequently asked questions
Does the sum include both ends?
Yes. From 1 to 100 has 100 terms, because the count is to − from + 1. The page prints the count so an off-by-one is visible.
What if the range runs backwards?
The page refuses it rather than returning a negative count. Enter the smaller bound first, which is what the formula assumes.
Why cap the range?
The closed form would handle any length, but the page also promises exactness within a safe integer bound. Beyond 10^15 or 100 million terms it refuses with the limit named.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.