Sum of the First n Squares Calculator

Sum the squares up to n².

How it is calculated

The tool adds 1² + 2² + … + n² with the closed form S = n × (n + 1) × (2n + 1) / 6, so no term-by-term addition is needed. n is how many squares you add, counting from 1: the last term is n² itself. It must be a whole number of at least 1; zero, negatives and decimals give no result. The answer is an exact integer shown with thousands separators. The arithmetic is done in whole numbers, dividing by 6 before the final multiplication, so every digit is exact. The largest n accepted is 3,000,000, whose sum is 9,000,004,500,000,500,000; anything larger would pass the 64-bit integer limit and shows no result rather than a rounded guess.

Worked example

Add the squares from 1² to 10². Here n = 10, n + 1 = 11 and 2n + 1 = 21. Multiply the three numbers: 10 × 11 × 21 = 2,310. Divide by 6: 2,310 / 6 = 385. The calculator shows 385. Adding by hand (1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100) gives the same total.

Try this example →

Common mistakes

  • Squaring the plain sum instead. (1 + 2 + … + n)² is the sum of cubes, not the sum of squares.
  • Reading the answer as the sum of cubes. The cube sum is n² × (n + 1)² / 4, which is much larger.
  • Forgetting the 2n + 1 factor, or using 2n − 1, which gives a different series.
  • Expecting the series to start somewhere other than 1². To sum squares from 5² to 10², subtract the sum to 4 from the sum to 10.
  • Entering a decimal such as 10.5 or a value above 3,000,000. Only whole n up to that limit gives a result.

About this calculator

The sum of the first n perfect squares, 1² + 2² + 3² + … + n², has a closed-form shortcut known since antiquity: n(n+1)(2n+1) ÷ 6, which gives the exact total without adding every term one by one. It is one of the classic results proved by mathematical induction in introductory algebra and number theory courses, alongside the simpler sum-of-first-n-integers formula.

Beyond being a standard proof exercise, this closed form appears in statistics as part of deriving variance and sum-of-squared-deviations formulas, in physics when summing discrete quantized energy levels, and in computer science as a textbook example for analyzing algorithm time complexity, since a nested loop that runs n² operations per outer iteration accumulates a total step count following exactly this formula.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators