Sum of Squares Calculator
The sum of the first n squares adds 1 squared, 2 squared, 3 squared and so on up to n squared. Rather than adding each term by hand, this calculator uses the exact closed form n(n + 1)(2n + 1) / 6, an identity proved by induction and used throughout calculus and statistics. Enter a positive whole number n and the tool returns the total, the average square value, the largest single square in the sum, and the count of terms added. The result is always an exact integer.
Sum of squares formula
Sum = n * (n + 1) * (2n + 1) / 6
Average = Sum / n
Largest term = n * n
Number of terms = n
The closed form returns the total in one step. Dividing the total by n gives the mean of the squared integers, and the largest single term is simply n squared.
About sums of squares
- The running sums begin 1, 5, 14, 30, 55, 91, 140, called square pyramidal numbers.
- Square pyramidal numbers count spheres stacked in a square-based pyramid.
- The identity n(n + 1)(2n + 1) / 6 can be proved by mathematical induction.
- In statistics, a different sum of squares measures total variation about a mean.
- The number 4,900 is the only number above 1 that is both square and a square pyramidal number.
Sum of squares: frequently asked questions
What is the sum of the first n squares?
It is 1 squared plus 2 squared plus 3 squared up to n squared. The closed form is n(n + 1)(2n + 1) divided by 6. For n = 3 this gives 1 + 4 + 9 = 14.
What is the formula for the sum of squares?
Sum = n times (n + 1) times (2n + 1), all divided by 6. This compact identity avoids adding each square individually and gives an exact integer result for any positive whole number n.
Is this the same as variance sum of squares?
No. This tool sums the squares of the integers 1 through n. In statistics, the sum of squares usually means the sum of squared deviations from a mean, which is a different quantity computed from a data set.
Why is the result always a whole number?
Among any three consecutive factors in n(n + 1)(2n + 1), the product is always divisible by 6, so the division leaves no remainder and the sum is always an integer.
What is the average of the first n squares?
Divide the sum by n. By the formula this equals (n + 1)(2n + 1) divided by 6, which gives the mean square value of the integers 1 through n.
Official sources
- NIST Digital Library of Mathematical Functions: Lattice Paths and Binomial Coefficients.
- National Institute of Standards and Technology DADS: Dictionary of Algorithms and Data Structures.
Reviewed by the CalculatorHub team, edited by James Graham, 16 June 2026. See our methodology.