Square Sum Calculator

1² + 2² + … + n², the sum of squares Σx² of a data list, and the sum of squared deviations SS.

  1. Enter valuesUse your own inputs or an example
  2. CalculateApply your selected settings
  3. View resultExplore the answer and explanation

Pick the kind of sum of squares and enter the numbers

Enter your values below to get started.

Examples:
Which sum of squares?
Use 1 for 1² + 2² + … + n². Negative bases are allowed.
Whole number up to 30 digits.
Separate values with commas, spaces or new lines. Decimals and negatives are fine.
Reset restores the default values.

Tips for this calculator

Consecutive squares: the sum from a² to b² equals S(b) − S(a − 1), with S(m) = m(m + 1)(2m + 1)/6.

Σx² squares each value first and then adds. (Σx)² adds first and then squares. For 3, 4, 5 they are 50 and 144.

SS measures spread: divide it by n − 1 for the sample variance s², or by n for the population variance σ².

Paste a column straight from a spreadsheet into the data box; new lines work as separators.

A square sum calculator adds squared numbers, and this one has 3 modes: consecutive squares 1² + 2² + … + n², the sum of squares Σx² of your own data, and the sum of squared deviations SS = Σ(x − x̄)² used for variance. The first mode applies n(n + 1)(2n + 1)/6 with exact integers. The data modes keep exact fractions, so 0.1² + 0.2² gives exactly 0.05.

What is a Sum of Squares?

A sum of squares is the total you get by squaring numbers and adding the results, such as 1² + 2² + 3² = 1 + 4 + 9 = 14. The phrase covers 3 different calculations, and mixing them up is the most common error with this topic.

  • Consecutive squares 1² + 2² + … + n²: a series with the closed form n(n + 1)(2n + 1)/6. For n = 10 the total is 385.
  • Sum of squares of data Σx²: square every value in a list and add. For 3, 4, 5 the total is 9 + 16 + 25 = 50.
  • Sum of squared deviations SS = Σ(x − x̄)²: subtract the mean first, then square and add. For 2, 4, 4, 4, 5, 5, 7, 9 (mean 5) the total is 32.

The consecutive total 1² + … + n² is the square pyramidal number Pn, the number of cannonballs in a pyramid with an n × n base. 5 layers hold 55 balls and 10 layers hold 385.

InteractiveCount the unit cells in squares of side 1 to n

Σx², (Σx)² and SS: Which One Do You Need?

Use Σx² for the raw sum of squared values, (Σx)² only when you need the square of the total, and SS when you need spread around the mean for variance or regression. The 3 numbers are linked by one identity:

SS=∑(xi−xˉ)2=∑xi2−(∑xi)2nSS = \sum (x_i - \bar{x})^2 = \sum x_i^2 - \frac{(\sum x_i)^2}{n}

For 2, 4, 4, 4, 5, 5, 7, 9: Σx² = 232, (Σx)² = 40² = 1,600 and n = 8, so SS = 232 − 1,600/8 = 232 − 200 = 32. Statistics textbooks write SS, Sxx or “corrected sum of squares” for the same value; the raw Σx² is the “uncorrected” sum of squares.

InteractiveSame data, 3 sums: Σx² vs (Σx)² vs SS

Sum of Squares Formula

The sum of the first n squares is n(n + 1)(2n + 1)/6, and the sum of squared deviations is Σx² − (Σx)²/n. The first formula turns 100 additions into 3 multiplications: 100 × 101 × 201 / 6 = 338,350.

Sum of the First n Squares

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

Archimedes used an equivalent result around 225 BC to find the volume of a cone in On Spirals. Check: n = 4 gives 4 × 5 × 9 / 6 = 30 = 1 + 4 + 9 + 16.

Squares from a to b

∑k=abk2=S(b)−S(a−1)\sum_{k=a}^{b} k^2 = S(b) - S(a-1)

For 11² to 20²: S(20) − S(10) = 2,870 − 385 = 2,485.

Sum of Squared Deviations

SS=∑xi2−(∑xi)2nSS = \sum x_i^2 - \frac{(\sum x_i)^2}{n}

Sample variance s² = SS/(n − 1); population variance σ² = SS/n. For the 8 values above, s² = 32/7 ≈ 4.5714 and σ² = 4.

InteractiveRunning total vs n(n + 1)(2n + 1)/6, row by row

Types of Square Sums

Besides 1² + … + n², the 3 most common square sums are odd squares, even squares and alternating squares, and each has its own closed form. All of them follow from n(n + 1)(2n + 1)/6.

InteractiveSwitch the type of square sum and compare the closed form

Consecutive squares

1² + 2² + … + n² = n(n + 1)(2n + 1)/6. For n = 5: 55.

Odd squares

1² + 3² + … + (2n − 1)² = n(2n − 1)(2n + 1)/3. For n = 5: 1 + 9 + 25 + 49 + 81 = 165.

Even squares

2² + 4² + … + (2n)² = 2n(n + 1)(2n + 1)/3, which is 4 times the consecutive sum. For n = 5: 220.

Alternating squares

1² − 2² + 3² − … ± n² = (−1)n+1 n(n + 1)/2. For n = 4: 1 − 4 + 9 − 16 = −10.

Squares of data

Σx² for any list, including decimals and negatives. For 1.5, 2.5, −3: 2.25 + 6.25 + 9 = 17.5.

How to Calculate a Sum of Squares by Hand

To add 1² through n² by hand, multiply n, n + 1 and 2n + 1, then divide by 6. For n = 10:

  1. n = 10, n + 1 = 11, 2n + 1 = 21.
  2. Multiply: 10 × 11 × 21 = 2,310.
  3. Divide by 6: 385.

For SS of a data list, find the mean, subtract it from each value, square each difference and add. The shortcut Σx² − (Σx)²/n gives the same answer with fewer subtractions.

InteractiveStep through 3 square sums by hand

    Sum of Squared Deviations and Variance

    The sum of squared deviations SS adds the squared distance from every value to the mean, and dividing SS by n − 1 gives the sample variance. Draw each deviation as a square with side |x − x̄| and SS is their total area.

    s2=SSn−1,σ2=SSns^2 = \frac{SS}{n-1}, \qquad \sigma^2 = \frac{SS}{n}

    For 2, 4, 4, 4, 5, 5, 7, 9 the deviations from x̄ = 5 are −3, −1, −1, −1, 0, 0, 2, 4. Their squares 9, 1, 1, 1, 0, 0, 4, 16 add to SS = 32, so σ = √4 = 2 and s = √(32/7) ≈ 2.1381. The divisor n − 1 is Bessel's correction, named after Friedrich Bessel; it makes s² an unbiased estimate of the population variance.

    InteractiveDraw a square for each deviation from the mean

    Writing Numbers as Sums of Squares

    Every whole number is a sum of at most 4 squares, a theorem Joseph-Louis Lagrange proved in 1770. Most numbers need fewer: 25 = 5², 50 = 5² + 5², 30 = 5² + 2² + 1², while 7 = 2² + 1² + 1² + 1² needs all 4.

    • 2 squares: Pierre de Fermat stated in 1640 that an odd prime is a sum of 2 squares exactly when it leaves remainder 1 on division by 4, such as 13 = 3² + 2². Leonhard Euler published the proof in 1752.
    • 3 squares: Adrien-Marie Legendre showed in 1798 that n is a sum of 3 squares unless n has the form 4a(8b + 7), such as 7, 15, 23 or 28.
    • Cannonball problem: Édouard Lucas asked in 1875 when 1² + … + n² is itself a perfect square. Apart from n = 1, the only answer is n = 24, where the sum is 4,900 = 70² (G. N. Watson proved this in 1918).
    InteractiveWrite any number as the fewest squares

    Sums of Squares in Regression: Least Squares

    The method of least squares fits a line by making the sum of squared errors SSE as small as possible. Adrien-Marie Legendre published the method in 1805, and Carl Friedrich Gauss published his version in 1809, saying he had used it since 1795 to predict the orbit of the asteroid Ceres.

    SST=SSR+SSE,R2=1−SSESSTSST = SSR + SSE, \qquad R^2 = 1 - \frac{SSE}{SST}

    SST is the SS of the y values, SSR the part the line explains and SSE the part left over. An R² of 0.95 means the line explains 95% of the total sum of squares. Squared errors are used instead of plain errors since positive and negative errors would otherwise cancel.

    InteractiveTurn the slope and watch the sum of squared errors

    Common Mistakes with Sums of Squares

    • Confusing Σx² with (Σx)²: for 3, 4, 5, Σx² = 50 but (Σx)² = 144.
    • Using Σx² as SS: SS subtracts the mean first. For 1 to 5, Σx² = 55 but SS = 10.
    • Wrong divisor for variance: SS/(n − 1) is the sample variance and SS/n the population variance. For SS = 32 and n = 8 they are 4.5714 and 4.
    • Using n(n + 1)/2: that formula adds 1 + 2 + … + n, not the squares. For n = 10 it gives 55, not 385.
    • Subtracting S(a) for a range: 11² + … + 20² is S(20) − S(10), not S(20) − S(11).
    InteractiveTrue or false: sums of squares
    1. 1² + 2² + … + 10² = 385.

    2. For the data 3, 4, 5, Σx² equals (Σx)².

    3. SS for 1, 2, 3, 4, 5 is 10.

    4. The sample variance divides SS by n.

    5. 7 can be written as a sum of 3 squares.

    Score: 0 / 5

    How to Use the Square Sum Calculator

    Pick one of the 3 modes, enter the bases or the data, and press Calculate. The result card names the mode in its heading so you always know which sum of squares you got.

    InteractiveLoad a ready-made sum of squares

    Each button fills the calculator and runs it.

    1. Pick the mode

      Consecutive squares 1² + … + n², Sum of squares of data Σx², or Squared deviations SS.

    2. Enter the numbers

      First and last base for consecutive squares; a list of values for the 2 data modes.

    3. Press Calculate

      The total appears exactly. SS mode adds the mean, variance and standard deviation.

    4. Check the table

      The table lists k, k² and the running total, or x, x − x̄ and (x − x̄)² in SS mode.

    Sum of Squares Examples

    Common square sums in all 3 modes. Click a row to load it.

    Sum of Squares Examples
    SumModeValueCalculator
    12+⋯+521^2 + \cdots + 5^2Consecutive55
    12+⋯+1021^2 + \cdots + 10^2Consecutive385
    12+⋯+10021^2 + \cdots + 100^2Consecutive338,350
    112+⋯+20211^2 + \cdots + 20^2Consecutive2,485
    32+42+523^2 + 4^2 + 5^2Σx²50
    1.52+2.52+(−3)21.5^2 + 2.5^2 + (-3)^2Σx²17.5
    SS{1,…,5}SS\{1,\ldots,5\}SS10
    SS{2,4,4,4,5,5,7,9}SS\{2,4,4,4,5,5,7,9\}SS32

    Popular Sum of Squares Problems

    Try each one, then reveal the answer or solve it in the calculator.

    1. Find the sum of the squares of the first 20 natural numbers.

      \sum_{k=1}^{20} k^2
      Show answer2{,}870
    2. Find the sum of the squares of the first 50 natural numbers.

      \sum_{k=1}^{50} k^2
      Show answer42{,}925
    3. How many cannonballs are in a square pyramid with 24 layers?

      \sum_{k=1}^{24} k^2
      Show answer4{,}900 = 70^2
    4. Add the squares from 5² to 15².

      \sum_{k=5}^{15} k^2
      Show answer1{,}210
    5. Find Σx² for the data 6, 8, 10.

      6^2 + 8^2 + 10^2
      Show answer200
    6. Find SS and the sample variance of 10, 12, 14, 16, 18.

      \sum (x_i - \bar{x})^2
      Show answerSS = 40,\ s^2 = 10

    Explore More Sum Calculators

    Discover 67 free sum calculators across different categories. Find the right calculator for your needs.

    Browse All 67 Calculators
    Questions and answers

    Frequently Asked Questions

    What is the formula for the sum of squares?

    The sum of the first n squares is n(n + 1)(2n + 1)/6. For a data list, the sum of squared deviations is SS = Σx² − (Σx)²/n.

    What is 1² + 2² + … + 10²?

    1² + 2² + … + 10² = 385, found as 10 × 11 × 21 / 6 = 2,310 / 6.

    What is the sum of the squares of the first 100 natural numbers?

    The sum is 338,350, found as 100 × 101 × 201 / 6.

    Is Σx² the same as (Σx)²?

    No, Σx² squares each value before adding, while (Σx)² adds first and squares the total. For 3, 4, 5 they are 50 and 144.

    Is the sum of squares the same as SS in statistics?

    No, in statistics SS usually means the sum of squared deviations from the mean, Σ(x − x̄)², not the raw Σx². For 1 to 5 the raw sum is 55 and SS is 10.

    How do I get variance from the sum of squares?

    Divide SS by n − 1 for the sample variance or by n for the population variance. SS = 32 with n = 8 gives s² ≈ 4.5714 and σ² = 4.

    What is the sum of the first n odd squares?

    1² + 3² + … + (2n − 1)² = n(2n − 1)(2n + 1)/3. For n = 5 the total is 165.

    Can every whole number be written as a sum of squares?

    Yes, Lagrange's four-square theorem (1770) shows that every whole number is a sum of at most 4 squares. Numbers of the form 4ᵃ(8b + 7), such as 7 and 15, need exactly 4.

    Can the square sum calculator handle decimals and negative numbers?

    Yes, both data modes accept decimals and negatives and keep exact fractions, so 1.5, 2.5, −3 gives Σx² = 17.5 exactly. The consecutive mode accepts negative whole-number bases.

    Conclusion

    The square sum calculator covers the 3 meanings of “sum of squares”: consecutive squares by n(n + 1)(2n + 1)/6, the raw sum Σx² of a data list, and the sum of squared deviations SS that leads to variance and standard deviation. Pick the mode by what you want to measure: a series total, a raw total of squared values, or spread around the mean.

    Not sure which mode fits your problem? Answer the questions below.

    InteractiveWhich sum of squares do you need?