The sum of the first n natural numbers is given by the formula Sn = n(n + 1) / 2. For example, the sum of 1 to 100 is 100 × 101 / 2 = 5050. This article explains the formula, its derivation, how to use it, and common mistakes to avoid.
Formula
The formula for the sum of the first n positive integers (1, 2, 3, …, n) is:
Sn = n(n + 1) / 2
Where:
- Sn = the total sum (no unit, it’s a count).
- n = the last number in the sequence (also the number of terms, since we start at 1).
This is a special case of the arithmetic series sum: S = (number of terms) × (first term + last term) / 2. Here first term = 1, last term = n, and number of terms = n, giving n(1 + n)/2.
Worked Example
Using the default value n = 100 (sum of 1 to 100):
S100 = 100 × (100 + 1) / 2 = 100 × 101 / 2 = 10100 / 2 = 5050
So the sum of all integers from 1 to 100 is exactly 5050. The calculator above gives the same result.
Assumptions
- The sequence starts at 1 and increases by 1 each step (consecutive integers).
- n is a positive integer (1, 2, 3, …). The formula also works for n = 0, giving 0, but we usually consider n ≥ 1.
- No other terms are skipped or repeated.
How the Formula Works (Derivation)
There are several ways to see why S = n(n+1)/2. A classic visual proof: write the sum twice, once forward and once backward:
S = 1 + 2 + 3 + … + (n-1) + n
S = n + (n-1) + … + 3 + 2 + 1
Add the two lines column by column. Each column sums to (n+1), and there are n columns, so 2S = n(n+1). Dividing by 2 gives S = n(n+1)/2.
Another way: think of a staircase of blocks. The sum 1+2+…+n is the number of blocks in a triangular arrangement. Two such triangles form an n by (n+1) rectangle, so the triangle has half the blocks: n(n+1)/2.
When to Use This Formula
Use it whenever you need the total of a set of consecutive integers starting at 1. Common applications include:
- Counting total items in a triangular arrangement (e.g., bowling pins: 1+2+…+10 = 55).
- Computing the sum of first n natural numbers in statistics or combinatorics.
- Estimating the number of handshakes in a group of n people: each person shakes hands with n-1 others, but each handshake is counted twice, so total = n(n-1)/2 – note that’s n-1, not n+1.
- Calculating the total number of comparisons in a simple sorting algorithm (like bubble sort worst case).
The formula also appears in physics (e.g., distance fallen under constant acceleration from rest, where total distance after n seconds is proportional to n(n+1)/2 if you sum per-second distances).
Common Mistakes and How to Avoid Them
- Using n(n-1)/2 instead of n(n+1)/2: The formula for sum 1 to n uses (n+1). The (n-1) version is for sum 0 to n-1 or for handshakes. Check the first term: if your sequence starts at 1, use n+1.
- Mixing up n with the number of terms when the sequence doesn’t start at 1: If you need the sum of consecutive integers from a to b (a>1), the formula is (a+b) × (b-a+1) / 2. For example, sum 5 to 10: (5+10)×6/2 = 45.
- Forgetting that n must be an integer: The formula works for any real number mathematically, but the sum of a discrete set of integers only makes sense for integer n. If you enter n = 5.5, the calculator still gives a number, but it doesn’t represent a sum of whole numbers.
- Rounding errors: For large n, n(n+1) can be huge. The formula is exact, but if you do it by hand, keep enough digits. For n = 1,000,000, the sum is 500,000,500,000 – that’s about 5×10^11, which fits in a 64-bit integer.
Related Formulas and Extensions
The sum of 1 to n is the first in a family of power sums:
- Sum of squares: 1² + 2² + … + n² = n(n+1)(2n+1)/6
- Sum of cubes: 1³ + 2³ + … + n³ = [n(n+1)/2]² = (sum of 1 to n)²
- Sum of arithmetic series generally: S = (number of terms) × (first + last)/2
These are useful in calculus (Riemann sums), discrete mathematics, and algorithm analysis. For example, the sum of squares appears when calculating the moment of inertia of a rod.
Why This Formula Is Useful in Real Life
Beyond classroom math, the formula shows up in surprising places:
- Counting games: In a round-robin tournament with n teams, the number of games is n(n-1)/2 (each team plays every other once).
- Financial calculations: If you save $1 in week 1, $2 in week 2, …, $n in week n, your total savings after n weeks is n(n+1)/2 dollars.
- Computer science: The number of operations in a nested loop where the inner loop runs i times for i=1..n is exactly n(n+1)/2.
- Construction: A triangular stack of objects (e.g., cannonballs) with n layers has n(n+1)/2 items.
Knowing the formula lets you compute these totals instantly without adding hundreds of numbers.
Frequently Asked Questions
What is the sum of 1 to 100?
Using the formula: 100 × 101 / 2 = 5050. This is a famous result, often attributed to Gauss as a schoolboy, but the formula itself is ancient.
Does the formula work for n = 0?
Yes, plugging n = 0 gives 0 × 1 / 2 = 0, which matches the empty sum. But in practice, we usually talk about positive integers.
What if I want the sum from 1 to n but n is not an integer?
The formula gives a number, but it doesn’t represent a sum of whole numbers. For example, n = 2.5 gives 2.5 × 3.5 / 2 = 4.375, which is not a sum of any set of consecutive integers. Use the formula only for integer n.
How is this related to the arithmetic series formula?
The general arithmetic series sum is S = (number of terms) × (first term + last term) / 2. For 1 to n, number of terms = n, first = 1, last = n, so it becomes n(1+n)/2.
What is the sum of 1 to n squared?
That’s a different formula: n(n+1)(2n+1)/6. For example, 1²+2²+3² = 14, and 3×4×7/6 = 14.