Search the complete library

What do you want to learn or calculate?

Quick linksAll calculatorsMath subjectsPractice questionsFormula library
← Discrete Math formulas

Sum of squares

Add squares of the first $n$ positive integers.

Discrete Math · Sums
$$\sum_{k=1}^{n}k^2=\frac{n(n+1)(2n+1)}6$$

Sum of squares is one of 2 sums formulas in the discrete math section of this library, and it is used at high school · university level.

Why sum of squares works

The forwards-and-backwards pairing trick fails here, because the gaps between squares keep growing. Instead the formula comes from a telescoping sum: adding up the differences (k + 1)³ − k³ collapses to a single cube, and rearranging what is left isolates the sum of squares. That is where the 6 in the denominator originates.

What each symbol means

$n$ is a nonnegative integer.

Sum of squares: when it holds

Use integer $n\ge0$.

When it stops applying

It counts only squares of consecutive whole numbers beginning at 1. For the squares from 5 to 10, subtract: 385 − 30 = 355. And it says nothing about squares of an arithmetic sequence like 2, 5, 8, which needs its own expansion.

Sum of squares: a worked example

$1^2+2^2+3^2=3(4)(7)/6=14$.

The mistake to avoid

What people do: Students square the total instead of adding the squares, computing (1 + 2 + 3)² for the sum of the first three squares.

Why it goes wrong: Those are two different quantities. Squaring the sum gives 36, while the sum of the squares is only 14, and the gap grows quickly as n rises.

Do this instead: Add first term by term: 1 + 4 + 9 = 14, which matches 3(4)(7)/6 = 14. Reading the notation carefully helps, since the exponent sits on the k inside the sum, not on the whole thing.

Sum of squares: step by step

  1. Name the unknown, and the unit the answer has to come out in.
  2. Match the symbols to your values. $n$ is a nonnegative integer.
  3. Check the conditions before substituting. Use integer $n\ge0$.
  4. Substitute, keep exact values to the last line, then test the sign, size, and unit against a rough estimate — the check that catches most discrete math slips.

Where this formula fits

Subject
Discrete Math formulas — 11 entries in this library
Topic
Sums
Level
High school · University

Formulas are easiest to keep when they sit inside a method rather than on a list. Use the links below to see where sum of squares comes from, to check a calculation against a tool, and to practise it until you can recall it without looking.

Questions about sum of squares

Is the sum of squares the same as the square of the sum?

No, and the difference is large. For the first ten numbers the sum of squares is 385 while the square of the sum is 3025, a classic puzzle whose answer is the gap of 2640.

How do I add the squares from 5 to 10?

Use the formula twice and subtract. The sum to 10 is 385, the sum to 4 is 30, so the answer is 355. Subtract at 4 rather than 5, since the term for 5 must stay in.

Is there a matching formula for cubes?

Yes, and it is delightfully neat: the sum of the first n cubes is the square of the sum of the first n whole numbers. For n = 3 that is 6² = 36, and 1 + 8 + 27 really is 36.

Where does this formula get used?

It shows up whenever you add up squared quantities, most often in computing variance in statistics and in Riemann sums that approach the integral of x² in calculus.

Stuck on a problem?

Work a sum of squares problem step by step

Type your own problem, or upload a photo of it. You get the method, the answer, and a check you can repeat yourself.