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
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
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
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
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
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)/6. Under the cards every term is laid out as a tile with its index above its value, so S1=1 to SN can be read in order.
The box accepts 1 to 200: 10 gives S10=100 with the sum 385, 30 gives S30=900 with the sum 9,455, and 300 is capped at 200 terms, ending at S200=40,000 with the sum 2,686,700; a single term gives S1=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 N. 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 1. Type the From index and the To index and click List range or press Enter. The cards give the Countb−a+1, the Smallest term Sa and the Largest term Sb, and the tiles below list every term in between with its index. The tab opens with 5 to 15, 11 terms from S5=25 to S15=225; indexes 10 to 20 give 11 terms from 100 to 400.
Both boxes must hold positive integers, the first no larger than the second, and the range may hold at most 200 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 169, which is S13; a red box with a cross answers no, as for 200, and the walkthrough on the right then shows the two nearest square numbers, S14=196 and S15=225. A large value is handled the same way: 10,000 is S100.
The box takes positive integers only; 0, 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 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 n and Value gives Sn with its index as a subscript. The tab opens with n=25, which gives S25=625; n=100 gives 10,000 and n=1000 gives 1,000,000. The box takes positive integers only; 0 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=n2, 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 n 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 n. Starting with one dot and adding a border of dots each step:
S1=1,S2=4,S3=9,S4=16,S5=25,…
The n-th square number is
Sn=n2=n⋅n
This is the simplest of all figurate-number formulas. Geometrically, Sn is the area of a square with integer side length n (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:
11+31+3+51+3+5+7=1=S1=4=S2=9=S3=16=S4
In general, Sn=1+3+5+⋯+(2n−1), the sum of the first n 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 counting identities behind these uses are in properties.
The Closed Form and the Gnomon
Closed form.Sn=n2 — 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 n by n square to an (n+1) by (n+1) square requires adding n dots along the right side, n dots along the bottom, and 1 corner dot — a total of 2n+1 dots, the (n+1)-th odd number.
Stacking gnomons one at a time gives:
Sn=k=1∑n(2k−1)
A classical proof that the sum of the first n odd numbers is n2.
Algebraic identity for the partial sum. The sum of the first n squares is
k=1∑nk2=6n(n+1)(2n+1)
This formula appears in calculus (Riemann sums approaching x3/3), in finance (running totals of squared error), and in basic number theory.
The Membership Test
Given a positive integer m, deciding whether it is a perfect square is straightforward.
The test.m is a square number if and only if m is a positive integer. Computationally: take the square root, round to the nearest integer s, and verify s2=m. If the equality holds, m=Ss. Otherwise m is not a perfect square.
Why rounding is needed. Floating-point square root is approximate. 169 might compute to 12.9999999… instead of exactly 13. Rounding before the verification step avoids missing valid squares.
Example. Is 169 a perfect square? Compute 169=13. Verify 132=169. Yes — 169=S13.
Non-example. Is 200 a perfect square? Compute 200≈14.14. Round to 14; verify 142=196=200. So 200 is not a perfect square. The nearest are S14=196 and S15=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) with S1=1. Each square adds the next odd number. • Sum of two consecutive triangulars: Tn+Tn−1=n2=Sn. Two consecutive triangular numbers sum to a square. • Difference of consecutive squares: Sn+1−Sn=2n+1. Consecutive squares differ by consecutive odd numbers. • Difference of squares: a2−b2=(a−b)(a+b). The most-used factoring identity. • Sum of first n squares: ∑k=1nk2=6n(n+1)(2n+1). Polynomial of degree 3 in n. • Sum of first n cubes: ∑k=1nk3=Tn2=(2n(n+1))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=c2 — sums of two squares equal to a square. The smallest is 32+42=52.
• Area. A square with integer side n has area n2. The most direct geometric meaning. • Quadratic formulas. The discriminant b2−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) and (x2,y2) is (x2−x1)2+(y2−y1)2, the sum of two squares. • Pythagorean theorem.a2+b2=c2 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 Sn. • 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/r2 with distance. The square arises from spreading over a surface area proportional to r2. • Energy. Kinetic energy 21mv2 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+1
Three squares aren't enough: 7 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).
Fermat's two-square theorem. A prime p is the sum of two squares if and only if p=2 or p≡1(mod4). So 5=1+4, 13=4+9, 17=1+16, but 3, 7, 11, 19 are not.
Quadratic residues. A number a is a quadratic residue modulo p if a≡x2(modp) for some x. The structure of which numbers are residues is governed by quadratic reciprocity, one of Gauss's deepest results.
Pell equation.x2−Dy2=1 for non-square D. 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 ∑(kn)2=(n2n).
• Confusing square with square root.Sn=n2 means: input the index n, output its square. The inverse is the square root: input m, output n=m (if m 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 might compute as 12.99999… in floating-point. Always round before verifying with s2=m. Languages with integer square root functions (like Python's isqrt) avoid this issue.
• Forgetting that 0 and 1 are special.02=0 and 12=1, so 0 and 1 are perfect squares by the usual definition. This explorer starts the sequence at S1=1, treating 0 as outside the sequence.
• Confusing square numbers with squared variables.Sn=n2 uses an integer index. The expression x2 for real or complex x is "the square of x" but only special values produce square numbers.
• Off-by-one when summing. The sum 1+4+9+⋯+n2 has n terms, equal to n(n+1)(2n+1)/6. The sum 1+4+9+⋯+N where N is itself a square (so N=n2) 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. 11, 14, 19 are not. The last-digit test only rejects, never confirms.
Triangular Numbers — Tn=n(n+1)/2. The first figurate family. Tn+Tn−1=Sn connects them.
Pentagonal Numbers — Pn=n(3n−1)/2. The next polygonal sequence in the figurate family.
Hexagonal Numbers — Hn=n(2n−1). Every hexagonal number is also triangular.
Cubic Numbers — n3. 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) with a2+b2=c2. The most famous Diophantine equation. Primitive triples are generated by a=m2−n2, b=2mn, c=m2+n2.
Sum of Squares — the function rk(n) counting representations of n as a sum of k squares. Studied extensively from Jacobi to modern modular-forms theory.
Quadratic Equation — ax2+bx+c=0. Square numbers arise in the discriminant and in completing the square.
Square Root — the inverse operation. Sn=n for integer n.
Quadratic Residue — modular arithmetic concept. a is a residue mod p if a≡x2(modp). 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.