Sum of Squares Formula - Definition, Proof, Examples

#Formula
TL;DR
The sum of squares formula gives 1 squared through n squared as n(n+1)(2n+1)/6, with a proof sketch, five worked examples and the statistical meaning.
BT
Bhanzu TeamLast updated on November 4, 20266 min read

Key Points

  • The sum of squares formula is ∑k=1nk2=n(n+1)(2n+1)6\sum_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6}, closing the sum into a single expression.

  • The OEIS lists these totals as the square pyramidal numbers, with the same closed form n(n+1)(2n+1)/6n(n+1)(2n+1)/6.

  • The name has a second meaning in statistics, where sum of squares refers to ∑(xi−xˉ)2\sum (x_i - \bar{x})^2, the summed squared deviations.

  • One of the three factors nn, n+1n+1 and 2n+12n+1 is always divisible by 3 and the pair nn, n+1n+1 supplies a factor of 2, so the result is always a whole number.

  • Squaring the sum is not the same as summing the squares, and conflating the two is the dominant error on this topic.

What Is the Sum of Squares Formula?

The sum of squares formula gives a closed expression for 12+22+⋯+n21^2 + 2^2 + \dots + n^2:

∑k=1nk2=n(n+1)(2n+1)6\sum_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6}

The On-Line Encyclopedia of Integer Sequences records these values as the square pyramidal numbers and gives exactly this closed form.

Why the Formula Gives a Whole Number

The division by 6 looks as though it might leave a fraction, and it never does. Among any three consecutive integers one is divisible by 3, and nn, n+1n+1, 2n+12n+1 always contains such a multiple.

The factor of 2 comes free from nn and n+1n+1, since consecutive integers cannot both be odd. Together they guarantee divisibility by 6.

A quick proof sketch uses the identity (k+1)3−k3=3k2+3k+1(k+1)^3 - k^3 = 3k^2 + 3k + 1. Summing both sides from k=1k = 1 to nn collapses the left side to (n+1)3−1(n+1)^3 - 1, and rearranging the right side for ∑k2\sum k^2 gives the formula.

Variable Key

Symbol

Meaning

Unit or type

Notes

nn

how many terms

positive integer

the last number squared

kk

summation index

integer

runs from 1 to nn

∑k=1nk2\sum_{k=1}^{n} k^2

the sum of squares

integer

the quantity being computed

n(n+1)(2n+1)6\frac{n(n+1)(2n+1)}{6}

closed form

integer

always divides exactly

Examples of the Sum of Squares Formula

Example 1

Find 12+22+32+421^2 + 2^2 + 3^2 + 4^2 using the formula.

4(5)(9)6=1806=30\frac{4(5)(9)}{6} = \frac{180}{6} = 30

Final answer: 30, matching 1+4+9+161 + 4 + 9 + 16.

Example 2

Find the sum of the squares of the first 10 whole numbers by squaring the sum.

The sum of 1 through 10 is 55, so squaring it looks like a shortcut:

552=302555^2 = 3025

That is far too large. Squaring the total multiplies every pair of terms together as well as each term by itself, so it counts far more than the ten squares asked for.

Using the formula instead:

10(11)(21)6=23106=385\frac{10(11)(21)}{6} = \frac{2310}{6} = 385

Final answer: 385. Note that (∑k)2=3025\left(\sum k\right)^2 = 3025 and ∑k2=385\sum k^2 = 385 are different quantities.

Example 3

Find ∑k=120k2\sum_{k=1}^{20} k^2.

20(21)(41)6=172206=2870\frac{20(21)(41)}{6} = \frac{17220}{6} = 2870

Final answer: 2870

Example 4

Find the sum of the squares from 6 to 10 inclusive.

Subtract the first five from the first ten:

10(11)(21)6−5(6)(11)6=385−55=330\frac{10(11)(21)}{6} - \frac{5(6)(11)}{6} = 385 - 55 = 330

Final answer: 330

Subtracting a shorter run from a longer one handles any partial range without a new formula.

Example 5

Find the statistical sum of squares for the sample 4, 6, 8.

Here the term means summed squared deviations, not squares of counting numbers. The mean is 6, and the deviations are −2,0,2-2, 0, 2:

∑(xi−xˉ)2=4+0+4=8\sum (x_i - \bar{x})^2 = 4 + 0 + 4 = 8

Final answer: 8, which divided by n−1=2n-1 = 2 gives the sample variance of 4.

Two Different Quantities Share This Name

Meaning

Formula

Where it is used

Sum of the first nn squares

n(n+1)(2n+1)6\frac{n(n+1)(2n+1)}{6}

series, counting, algebra

Sum of squared deviations

∑(xi−xˉ)2\sum (x_i - \bar{x})^2

variance, standard deviation

Total sum of squares (ANOVA)

the corrected sum of squares about the grand mean

analysis of variance

Square of the sum

(∑k)2\left(\sum k\right)^2

a different value entirely

The NIST e-Handbook uses the statistical sense, splitting a total sum of squares into a treatment part and an error part when analysing variance.

Sum of Squares, Where Things Go Sideways

Mistake 1: Squaring the sum instead of summing the squares

Where it slips in: Both phrases contain the same words, and the sum is quicker to compute.

Don't do this: (1+2+⋯+n)2(1+2+\dots+n)^2

The correct way: 12+22+⋯+n2=n(n+1)(2n+1)61^2 + 2^2 + \dots + n^2 = \frac{n(n+1)(2n+1)}{6}. For n=10n = 10 the two give 3025 and 385, so the gap is not subtle.

Students who write out the first three terms before reaching for any formula catch this instantly, because 1+4+91 + 4 + 9 looks nothing like 3636.

Mistake 2: Using nn as the count when the range does not start at 1

Where it slips in: The formula assumes the sum begins at 121^2.

Don't do this: Apply n(n+1)(2n+1)6\frac{n(n+1)(2n+1)}{6} with n=5n = 5 for the squares from 6 to 10.

The correct way: Compute the full sum to 10 and subtract the sum to 5, as in Example 4.

Mistake 3: Mixing the two meanings of the term

Where it slips in: A statistics question says "sum of squares" and the algebraic identity is applied.

Don't do this: Use n(n+1)(2n+1)6\frac{n(n+1)(2n+1)}{6} on a data set.

The correct way: Check whether the squares are of the counting numbers or of deviations from a mean. The presence of a data set rather than a value of nn settles it.

Bottom Line

  • The sum of squares formula is ∑k=1nk2=n(n+1)(2n+1)6\sum_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6}.

  • These totals are the square pyramidal numbers, counting spheres stacked in a square pyramid.

  • The division by 6 is always exact, because the three factors supply a 2 and a 3 between them.

  • The same phrase means summed squared deviations in statistics, so check which quantity a question wants.

  • To work through series with a teacher, explore an algebra tutor or math classes online.

Where to Go From Here

Find ∑k=115k2\sum_{k=1}^{15} k^2, then the sum of the squares from 11 to 15 by subtraction, and check that the two shorter sums add back to the first.

Want a live Bhanzu trainer to walk through more series problems? Book a free demo class.

Read More

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is the sum of squares formula?
∑k=1nk2=n(n+1)(2n+1)6\sum_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6}, the total of the squares of the first nn whole numbers.
Why does the sum of squares formula divide by 6 and still give an integer?
Because nn, n+1n+1 and 2n+12n+1 always contain a multiple of 3, and nn with n+1n+1 guarantees a factor of 2. Together those supply the 6, so the division is always exact.
Is the sum of squares the same as the square of the sum?
No. For the first 10 whole numbers the sum of squares is 385 while the square of the sum is 3025.
What does sum of squares mean in statistics?
The sum of squared deviations from the mean, ∑(xi−xˉ)2\sum (x_i - \bar{x})^2, which is the numerator of the variance.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →