Number Theory
Intermediate

Sum of First n Squares

Closed form for the sum of the first n squares.

Formula

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

Live Calculator

Members

Variables

nUpper limit

Example

1² + 2² + 3² = 3·4·7/6 = 14. ✓

How it works

This formula gives the total of the perfect squares from 1² up to n² without adding them one by one. It works because the sum of square numbers grows in a very regular cubic pattern, and the expression n(n+1)(2n+1)/6 is the compact polynomial that matches that pattern for every whole number n. You can think of it as a shortcut that replaces a long arithmetic calculation with one exact formula.

When to use it

Use this when you need 1² + 2² + ... + n² in algebra, combinatorics, physics, or data analysis. It is especially useful for deriving formulas, checking sums quickly, or solving problems involving squared distances, variances, or counting patterns.

Worked example, step by step

Find 1² + 2² + 3² + 4² + 5². Use the formula: n(n+1)(2n+1)/6 Substitute n = 5: 5(5+1)(2·5+1)/6 Simplify: 5·6·11/6 Cancel the 6: 5·11 = 55 Final answer: 1² + 2² + 3² + 4² + 5² = 55

Common mistakes to avoid

  • Using n instead of the upper limit only for the last term, instead of summing from 1 through n
  • Forgetting to square each term before adding when checking the result manually
  • Miscalculating the factors n+1 or 2n+1, especially when n is large

Did You Know?

The sum of the first n squares appears in physics when computing moments of inertia.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026