How this calculation works
The difference between the sums at n and n−1 is exactly n². This gives a direct check on the formula.
n(n+1)(2n+1)/6A worked example
1² + 2² + … + 10² = 385.
Good to know
An empty sum is zero.
Reference: NIST DLMF, Functions of Number Theory (opens in a new tab) ↗
Evaluate the square-sum formula
For ten terms, substitute n = 10 into n(n + 1)(2n + 1)/6. This gives 10 × 11 × 21/6 = 385. The summed terms are 1² through 10², with no missing integer bases. The result is the total of their squared values.
For a smaller check, n = 3 gives 3 × 4 × 7/6 = 14, matching 1 + 4 + 9. The diagram displays these three square areas. It illustrates why summing squares grows faster than simply adding the bases 1 + 2 + 3.
Keep the square outside the correct operation
Adding the first three integers and then squaring gives (1 + 2 + 3)² = 36, which differs from the square sum 14. Expanding a square of a sum introduces cross terms such as 2 × 1 × 2. Those terms are absent when the individual squares are added.
The Sum of the first n cubes calculator uses the square of a triangular number, an identity specific to that different sum. Here the leading cubic term is about n³/3 for large n. If you need the square sum from base a through b, subtract the sum through a − 1 from the sum through b. For 4² + 5², the difference is 55 − 14 = 41.
A few questions, answered
Does n mean the final square or its base?
It is the final base and also the number of terms. Entering 10 sums through 10², or 100.
What does zero return?
The empty sum is zero, and the formula agrees when n = 0.