The rule
sum = count × (first + last) ÷ 2
Why it works
Pair the first number with the last, the second with the second-to-last, and so on: every pair adds to the same total. Multiply that total by how many pairs there are and you have the sum, without touching the numbers in between.
How to do it by hand
- Count how many numbers there are: last − first + 1
- Add the first and the last
- Multiply the two
- Halve the result, because each pair was counted twice
What is worth knowing
The story is that Gauss's teacher set the class to add 1 to 100 as busywork, and Gauss produced 5050 almost immediately by pairing 1 with 100, 2 with 99, and so on: fifty pairs of 101. The story may be embellished but the method is exactly right, and it generalises to any arithmetic progression. The same reasoning gives the formula for triangular numbers, and it is the simplest example of turning a loop into a closed form — the difference between a hundred additions and two.