Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Square Numbers Calculator






What is a Square Number?

A square number is the count of dots needed to form a square of side nn. Starting with one dot and adding a border of dots each step:

S1=1,S2=4,S3=9,S4=16,S5=25,S_1 = 1, \quad S_2 = 4, \quad S_3 = 9, \quad S_4 = 16, \quad S_5 = 25, \quad \ldots


The nn-th square number is

Sn=n2=nnS_n = n^2 = n \cdot n


This is the simplest of all figurate-number formulas. Geometrically, SnS_n is the area of a square with integer side length nn (counted in unit squares), or equivalently the number of unit lattice points in such a square.

Alternative characterization. Square numbers are the sums of consecutive odd numbers from 1:

1=1=S11+3=4=S21+3+5=9=S31+3+5+7=16=S4\begin{aligned} 1 &= 1 = S_1 \\ 1 + 3 &= 4 = S_2 \\ 1 + 3 + 5 &= 9 = S_3 \\ 1 + 3 + 5 + 7 &= 16 = S_4 \end{aligned}


In general, Sn=1+3+5++(2n1)S_n = 1 + 3 + 5 + \cdots + (2n - 1), the sum of the first nn odd numbers.

For deeper coverage see square number, perfect square, and figurate numbers.

The Closed Form and the Gnomon

Closed form. Sn=n2S_n = n^2 — the simplest formula in the figurate family.

Geometric proof via gnomons. A gnomon is the L-shaped piece added to extend one square into the next. Going from an nn by nn square to an (n+1)(n + 1) by (n+1)(n + 1) square requires adding nn dots along the right side, nn dots along the bottom, and 1 corner dot — a total of 2n+12n + 1 dots, the (n+1)(n + 1)-th odd number.

Stacking gnomons one at a time gives:

Sn=k=1n(2k1)S_n = \sum_{k=1}^{n} (2k - 1)


A classical proof that the sum of the first nn odd numbers is n2n^2.

Algebraic identity for the partial sum. The sum of the first nn squares is

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


This formula appears in calculus (Riemann sums approaching x3/3x^3/3), in finance (running totals of squared error), and in basic number theory.

The Membership Test

Given a positive integer mm, deciding whether it is a perfect square is straightforward.

The test. mm is a square number if and only if m\sqrt{m} is a positive integer. Computationally: take the square root, round to the nearest integer ss, and verify s2=ms^2 = m. If the equality holds, m=Ssm = S_s. Otherwise mm is not a perfect square.

Why rounding is needed. Floating-point square root is approximate. 169\sqrt{169} might compute to 12.999999912.9999999\ldots instead of exactly 1313. Rounding before the verification step avoids missing valid squares.

Example. Is 169 a perfect square? Compute 169=13\sqrt{169} = 13. Verify 132=16913^2 = 169. Yes — 169=S13169 = S_{13}.

Non-example. Is 200 a perfect square? Compute 20014.14\sqrt{200} \approx 14.14. Round to 1414; verify 142=19620014^2 = 196 \neq 200. So 200 is not a perfect square. The nearest are S14=196S_{14} = 196 and S15=225S_{15} = 225.

Number-theoretic patterns. A perfect square never ends in 2, 3, 7, or 8 (in base 10). This gives a quick rejection filter before computing the square root, useful in mental arithmetic.

Properties and Identities

Square numbers have a rich set of identities — many of them appear in elementary algebra and number theory.

Recurrence: Sn=Sn1+(2n1)S_n = S_{n-1} + (2n - 1) with S1=1S_1 = 1. Each square adds the next odd number.
Sum of two consecutive triangulars: Tn+Tn1=n2=SnT_n + T_{n-1} = n^2 = S_n. Two consecutive triangular numbers sum to a square.
Difference of consecutive squares: Sn+1Sn=2n+1S_{n+1} - S_n = 2n + 1. Consecutive squares differ by consecutive odd numbers.
Difference of squares: a2b2=(ab)(a+b)a^2 - b^2 = (a - b)(a + b). The most-used factoring identity.
Sum of first $n$ squares: k=1nk2=n(n+1)(2n+1)6\sum_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6}. Polynomial of degree 3 in nn.
Sum of first $n$ cubes: k=1nk3=Tn2=(n(n+1)2)2\sum_{k=1}^{n} k^3 = T_n^2 = \left(\frac{n(n+1)}{2}\right)^2. The sum of cubes is the square of the sum.
Lagrange's four-square theorem: every non-negative integer is a sum of at most four squares. The number of representations is given by Jacobi's formula.
Pythagorean triples: integer solutions to a2+b2=c2a^2 + b^2 = c^2 — sums of two squares equal to a square. The smallest is 32+42=523^2 + 4^2 = 5^2.

Common Applications

Square numbers appear wherever area, energy, or pairwise interactions scale quadratically.

Area. A square with integer side nn has area n2n^2. The most direct geometric meaning.
Quadratic formulas. The discriminant b24acb^2 - 4ac is a difference of a square and a multiple. Real roots exist exactly when this is non-negative; rational roots require it to be a perfect square.
Distance formula. The squared distance between (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is (x2x1)2+(y2y1)2(x_2 - x_1)^2 + (y_2 - y_1)^2, the sum of two squares.
Pythagorean theorem. a2+b2=c2a^2 + b^2 = c^2 for a right triangle. Both classical and modern geometry rely on this.
Least squares. Statistical regression minimizes the sum of squared residuals. The squares come from quadratic loss; the minimum has a closed form involving sums of SnS_n.
Variance. Statistical variance is the average of squared deviations from the mean. Squared deviations weight outliers more than absolute deviations.
Inverse square laws. Gravity, electric force, light intensity, sound intensity — all decay as 1/r21/r^2 with distance. The square arises from spreading over a surface area proportional to r2r^2.
Energy. Kinetic energy 12mv2\tfrac{1}{2} m v^2 scales with the square of velocity. Doubling speed quadruples energy.

Square Numbers in Number Theory

Squares are central to many results in number theory. A few of the most important.

Lagrange's four-square theorem. Every non-negative integer is the sum of at most four perfect squares. Examples:

7=4+1+1+1,15=9+4+1+1,23=9+9+4+17 = 4 + 1 + 1 + 1, \quad 15 = 9 + 4 + 1 + 1, \quad 23 = 9 + 9 + 4 + 1


Three squares aren't enough: 77 cannot be written as the sum of three perfect squares. The characterization (Legendre's three-square theorem) excludes numbers of the form 4a(8b+7)4^a (8b + 7).

Fermat's two-square theorem. A prime pp is the sum of two squares if and only if p=2p = 2 or p1(mod4)p \equiv 1 \pmod 4. So 5=1+45 = 1 + 4, 13=4+913 = 4 + 9, 17=1+1617 = 1 + 16, but 33, 77, 1111, 1919 are not.

Quadratic residues. A number aa is a quadratic residue modulo pp if ax2(modp)a \equiv x^2 \pmod p for some xx. The structure of which numbers are residues is governed by quadratic reciprocity, one of Gauss's deepest results.

Pell equation. x2Dy2=1x^2 - D y^2 = 1 for non-square DD. Solutions involve continued fractions and generate the square-triangular numbers and other figurate intersections.

Perfect squares in Pascal's triangle. Row sums and column sums produce squares in surprising places, including the identity (nk)2=(2nn)\sum \binom{n}{k}^2 = \binom{2n}{n}.

Common Mistakes

Confusing square with square root. Sn=n2S_n = n^2 means: input the index nn, output its square. The inverse is the square root: input mm, output n=mn = \sqrt{m} (if mm is a perfect square). The membership test uses the square root; the lookup uses the square.

Floating-point rounding errors in the membership test. 169\sqrt{169} might compute as 12.9999912.99999\ldots in floating-point. Always round before verifying with s2=ms^2 = m. Languages with integer square root functions (like Python's isqrt\mathrm{isqrt}) avoid this issue.

Forgetting that 0 and 1 are special. 02=00^2 = 0 and 12=11^2 = 1, so 0 and 1 are perfect squares by the usual definition. This explorer starts the sequence at S1=1S_1 = 1, treating 0 as outside the sequence.

Confusing square numbers with squared variables. Sn=n2S_n = n^2 uses an integer index. The expression x2x^2 for real or complex xx is "the square of xx" but only special values produce square numbers.

Off-by-one when summing. The sum 1+4+9++n21 + 4 + 9 + \cdots + n^2 has nn terms, equal to n(n+1)(2n+1)/6n(n+1)(2n+1)/6. The sum 1+4+9++N1 + 4 + 9 + \cdots + N where NN is itself a square (so N=n2N = n^2) ends at the same place — just stated differently.

Last-digit rejection over-eagerness. A number ending in 0, 1, 4, 5, 6, or 9 might be a perfect square — but only might. 1111, 1414, 1919 are not. The last-digit test only rejects, never confirms.

Related Sequences and Concepts

Triangular NumbersTn=n(n+1)/2T_n = n(n+1)/2. The first figurate family. Tn+Tn1=SnT_n + T_{n-1} = S_n connects them.

Pentagonal NumbersPn=n(3n1)/2P_n = n(3n-1)/2. The next polygonal sequence in the figurate family.

Hexagonal NumbersHn=n(2n1)H_n = n(2n-1). Every hexagonal number is also triangular.

Cubic Numbersn3n^3. The 3D analog of squares.

Perfect Square — the same concept as a square number, usually used in number-theoretic contexts. Every square number is a perfect square; the terms are interchangeable.

Square Triangular Numbers — numbers that are both square and triangular: 1, 36, 1225, 41616, ... Solutions to a Pell equation.

Pythagorean Triples — integer triples (a,b,c)(a, b, c) with a2+b2=c2a^2 + b^2 = c^2. The most famous Diophantine equation. Primitive triples are generated by a=m2n2a = m^2 - n^2, b=2mnb = 2mn, c=m2+n2c = m^2 + n^2.

Sum of Squares — the function rk(n)r_k(n) counting representations of nn as a sum of kk squares. Studied extensively from Jacobi to modern modular-forms theory.

Quadratic Equationax2+bx+c=0ax^2 + bx + c = 0. Square numbers arise in the discriminant and in completing the square.

Square Root — the inverse operation. Sn=n\sqrt{S_n} = n for integer nn.

Quadratic Residue — modular arithmetic concept. aa is a residue mod pp if ax2(modp)a \equiv x^2 \pmod p. Half of nonzero residues mod a prime are quadratic residues.

Variance and Standard Deviation — statistical measures involving squared deviations. The "least squares" approach to regression and the central limit theorem depend on the algebra of squares.