What is the sum of squares?
The sum of squares of the first n positive integers is the total you get by squaring each whole number from 1 up to n and adding the results: \(1^2 + 2^2 + 3^2 + \ldots + n^2\). Instead of adding every term one at a time, you can use a famous closed-form formula that gives the answer in a single step, no matter how large n is.
The formula explained
The compact identity is:
$$\sum_{k=1}^{n} k^2 = \frac{n\left(n+1\right)\left(2\,n+1\right)}{6}$$
Here n is the largest integer in your sequence. Multiply n by \((n+1)\) and by \((2n+1)\), then divide by 6. The result is always a whole number because the product of these three factors is always divisible by 6. This calculator also reports the related sum of integers, \(\frac{n(n+1)}{2}\), and the mean of the squares.
How to use this calculator
Enter the upper limit n — the last integer in the series — and the tool returns the exact sum instantly. Use it to check homework, verify code, or speed up statistics work, since sums of squares appear in variance, standard deviation, and regression formulas.
Worked example
Suppose n = 5. The terms are 1, 4, 9, 16, 25, which add to 55. Using the formula: $$\frac{5 \times 6 \times 11}{6} = \frac{330}{6} = 55.$$ The closed form matches the direct addition perfectly.
How to Compute Σk² by Hand
The sum of the first n squares, \(1^2 + 2^2 + \dots + n^2\), has the closed form \(\frac{n(n+1)(2n+1)}{6}\). The steps below apply it to any whole number n ≥ 1.
- Pick n. This is the last integer whose square you want to include. For example, n = 10.
- Compute n + 1 and 2n + 1. For n = 10: n + 1 = 11 and 2n + 1 = 21.
- Write the three factors as a product. Here that is 10 × 11 × 21.
- Divide by 6, cancelling early. One of n or n + 1 is always even, and one of the three factors is always a multiple of 3, so the product is always divisible by 6. Divide a factor by 2 and a factor by 3 before multiplying to keep the numbers small: 21 ÷ 3 = 7 and 10 ÷ 2 = 5, which leaves 5 × 11 × 7.
- Multiply what is left. $$\sum_{k=1}^{10} k^2 = \frac{10 \cdot 11 \cdot 21}{6} = 5 \cdot 11 \cdot 7 = 385$$
- Sanity-check with direct addition (small n). 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 = 385, which matches. Another quick check is n = 5: \(\frac{5 \cdot 6 \cdot 11}{6} = 55\), and 1 + 4 + 9 + 16 + 25 = 55.
Why the formula works (telescoping idea)
Start from the identity \((k+1)^3 - k^3 = 3k^2 + 3k + 1\). Add this over k = 1 to n. The left side telescopes, because every middle term cancels, and leaves \((n+1)^3 - 1\). The right side becomes \(3S + 3\cdot\frac{n(n+1)}{2} + n\), where \(S = \sum k^2\). Solving for S gives
$$3S = (n+1)^3 - (n+1) - \frac{3n(n+1)}{2} = \frac{n(n+1)(2n+1)}{2}, \quad\text{so}\quad S = \frac{n(n+1)(2n+1)}{6}.$$
FAQ
Does this work for any n? Yes — for any positive whole number n. Very large values still compute instantly thanks to the formula.
Why divide by 6? The product \(n(n+1)(2n+1)\) is always a multiple of 6, which is why the formula yields an integer.
Can I include 0? Adding \(0^2 = 0\) does not change the sum, so the result for n stays the same whether or not you count zero.