Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Square Numbers Calculator

How to use Square Numbers Calculator
  1. Pick a mode with the four tabs across the top of the card: List first N, List a – b, Test a number or Lookup by index; the ? beside each tab describes it. Learn more about the modes
  2. In List first N, type how many terms to show in Show first and click Update; the cards give the count, the largest term and the sum, and the tiles list every term. Learn more about listing terms
  3. In List a – b, type the From index and the To index and click List range; a red box explains a bad range. Learn more about ranges
  4. In Test a number, type a positive integer in Test number and click Check; a green box names the index, a red box says it is not a square number. Learn more about the test
  5. In Lookup by index, type the position in Index n and click Get term. Learn more about lookups
  6. The panel on the right explains the current mode and walks through the arithmetic with your own numbers; it changes with every tab and click. Learn more about the panel





Listing the First N Terms

DemoTen terms, thirty terms, the cap, one term
Step 0 of 4
The explorer opens on the List first N tab, one of four tabs across the top of the card; the small ? beside each tab shows what the mode does. Type how many terms you want in the Show first box and click Update or press Enter. Three cards answer at once: Showing gives the count, Largest the last term with its index, and Sum the total of the listed terms, which for square numbers is N(N+1)(2N+1)/6N(N+1)(2N+1)/6. Under the cards every term is laid out as a tile with its index above its value, so S1=1S_1 = 1 to SNS_N can be read in order.

The box accepts 11 to 200200: 1010 gives S10=100S_{10} = 100 with the sum 385385, 3030 gives S30=900S_{30} = 900 with the sum 9,4559,455, and 300300 is capped at 200200 terms, ending at S200=40,000S_{200} = 40,000 with the sum 2,686,7002,686,700; a single term gives S1=1S_1 = 1. Large values are printed with thousands separators. A count of 0, a decimal or an empty box is refused with "Enter a positive integer." There is no Reset button: type a new count and click Update again. The panel on the right, List first N, states the rule the tiles come from, and its walkthrough repeats the last term and the sum with your own NN. What the terms are is explained in what is a square number.

Listing a Range of Indexes

DemoThe range tab, a new range, two bad ranges
Step 0 of 4
Click the List a – b tab to list the terms between two positions instead of starting from 11. Type the From index and the To index and click List range or press Enter. The cards give the Count b−a+1b - a + 1, the Smallest term SaS_a and the Largest term SbS_b, and the tiles below list every term in between with its index. The tab opens with 55 to 1515, 11 terms from S5=25S_{5} = 25 to S15=225S_{15} = 225; indexes 1010 to 2020 give 11 terms from 100100 to 400400.

Both boxes must hold positive integers, the first no larger than the second, and the range may hold at most 200200 terms; otherwise a red box explains: "Enter two positive integer indexes", "From-index must be less than or equal to to-index", or "Range too wide — cap is 200 terms". The panel on the right, List a – b, explains the mode, and its walkthrough names the smallest and largest term of your range. The rule each tile uses is explained in the closed form and the gnomon.

Testing a Number

DemoThe test tab, a non-member, a member, 0
Step 0 of 4
Click the Test a number tab to ask whether a given positive integer is a square number. Type it in the Test number box and click Check or press Enter. A green box with a tick answers yes and names the index, as for the opening value 169169, which is S13S_{13}; a red box with a cross answers no, as for 200200, and the walkthrough on the right then shows the two nearest square numbers, S14=196S_{14} = 196 and S15=225S_{15} = 225. A large value is handled the same way: 10,00010,000 is S100S_{100}.

The box takes positive integers only; 00, a negative number or a decimal is refused with "Enter a positive integer". The test behind the answer is exact: the explorer checks whether m\sqrt{m} is a whole number; if it is, that whole number is the index, otherwise the two nearest squares are shown, so no list has to be searched. The panel on the right, Test a number, states this rule, and its walkthrough carries out the arithmetic for your number. The rule itself is explained in the membership test.

Looking Up a Term by Index

DemoThe lookup tab, two indexes, n = 0
Step 0 of 4
Click the Lookup by index tab to compute one term directly. Type the position in the Index n box and click Get term or press Enter. Two cards answer: Index repeats nn and Value gives SnS_n with its index as a subscript. The tab opens with n=25n = 25, which gives S25=625S_{25} = 625; n=100n = 100 gives 10,00010,000 and n=1000n = 1000 gives 1,000,0001,000,000. The box takes positive integers only; 00 is refused with "Enter a positive integer index".

The panel on the right has two parts in every mode. How it works names the rule the mode uses, here Sn=n2S_n = n^2, and links to the section of this page that explains it; Walkthrough applies the rule to the numbers you typed, so for the lookup it shows the arithmetic with your nn filled in. Both change as soon as you switch tabs or click a button. The rule and where it comes from are in the closed form and the gnomon.

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=n⋅nS_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+⋯+(2n−1)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 definition is given in definition and the sequence is placed among the others in square numbers.

The gnomon is the subject of recursive form and odd number sums.

The square-root test and the other properties are collected in properties.

The sum identity is proved in sum of squares and the triangular link in connections to triangular numbers.

The counting identities behind these uses are in properties.

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(2k−1)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.9999999…12.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 200≈14.14\sqrt{200} \approx 14.14. Round to 1414; verify 142=196≠20014^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=Sn−1+(2n−1)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+Tn−1=n2=SnT_n + T_{n-1} = n^2 = S_n. Two consecutive triangular numbers sum to a square.
• Difference of consecutive squares: Sn+1−Sn=2n+1S_{n+1} - S_n = 2n + 1. Consecutive squares differ by consecutive odd numbers.
• Difference of squares: a2−b2=(a−b)(a+b)a^2 - b^2 = (a - b)(a + b). The most-used factoring identity.
• Sum of first nn 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 nn 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 b2−4acb^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 (x2−x1)2+(y2−y1)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 p≡1(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 a≡x2(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. x2−Dy2=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}.

The number-theoretic facts are gathered in properties; the neighbouring sequence is triangular numbers.

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.99999…12.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.

Index conventions and the two ways of defining a sequence are explained in definition and notation and explicit and recursive definitions.