Sum of Natural Numbers Calculator

Sum 1 through n with Gauss’s formula.

Result

5,050

How it is calculated

The tool adds 1 + 2 + … + n with Gauss's closed form instead of looping: S = n × (n + 1) / 2. The idea is pairing: the first and last terms add to n + 1, the second and second-to-last also add to n + 1, and there are n/2 such pairs. n must be a whole number of at least 1; zero, negatives, decimals such as 2.5 and empty input give no result. The arithmetic is done in exact integers, halving whichever of n and n + 1 is even before multiplying, and the answer is shown with thousands separators and every digit correct. The largest n accepted is 4,294,967,295 (sum 9,223,372,034,707,292,160); anything above that shows no result rather than an approximate number.

Worked example

Sum the whole numbers from 1 to 100. Here n = 100 and n + 1 = 101. Multiply: 100 × 101 = 10,100. Halve it: 10,100 / 2 = 5,050. The calculator shows 5,050. You can check it by pairing: 1 + 100, 2 + 99 and so on make 50 pairs of 101, and 50 × 101 = 5,050.

Try this example →

Common mistakes

  • Dividing by 2 first on an odd n. Multiply n by n + 1 first; one of the two is always even, so the product halves cleanly.
  • Using n × (n − 1) / 2, which sums only up to n − 1.
  • Entering a count of terms when the series does not start at 1. This tool always starts at 1; for 10 to 20 subtract the sum to 9 from the sum to 20.
  • Typing a decimal such as 12.5 for n, or 0 for an empty sum. The tool needs a whole number of at least 1 and shows no result otherwise.
  • Entering an n above about 4.29 billion and expecting an answer. Beyond 4,294,967,295 the tool refuses rather than guess at digits.

About this calculator

The sum of the first n natural numbers, 1 + 2 + 3 + ... + n, is given by the closed-form formula n × (n + 1) divided by 2 — famously attributed to a young Carl Friedrich Gauss, who is said to have instantly solved the sum of 1 through 100 in his schoolroom by pairing the first and last terms, each pair summing to 101.

This formula is a foundational result in discrete mathematics, used to derive other summation formulas, count the number of handshakes in a group or edges in a complete graph, calculate triangular numbers, and analyze the running time of nested-loop algorithms in computer science, where a loop that does 1, then 2, then 3 operations up to n follows exactly this pattern.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators