Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Square Numbers






Perfect Squares as a Sequence

The square numbers 1,4,9,16,25,…1, 4, 9, 16, 25, \ldots are among the most recognizable sequences in mathematics. Each is the product of an integer with itself, each can be visualized as dots filling a square grid, and each is a sum of consecutive odd numbers. Their properties connect to arithmetic sequences, triangular numbers, and divisibility.



Definition

Six piles of square tiles: 12, 16, 20, 25, 30 and 36. Which piles can be laid out as one complete square, with no tile left over?
Every pile can be laid in rows of some length; the question is whether the rows can be exactly as long as there are rows.
Dots in squares of side 1, 2, 3 and 4: 1, 4, 9 and 16 dots 14916Squares of side 1, 2, 3 and 4
Laying them out settles it: 16, 25 and 36 make full squares; 12, 20 and 30 do not.
tilesclosest layoutfull square?
123 rows of 4no
164 rows of 4yes
204 rows of 5no
255 rows of 5yes
305 rows of 6no
366 rows of 6yes
12, 20 and 30 make rectangles but never squares: a square needs as many rows as columns.
12=3⋅412 = 3 \cdot 4, 20=4⋅520 = 4 \cdot 5 and 30=5⋅630 = 5 \cdot 6 are each one column too wide. The piles that work are 4⋅44 \cdot 4, 5⋅55 \cdot 5 and 6⋅66 \cdot 6 — a whole number times itself.
The definition
The nn-th square number is Sn=n2S_n = n^2, the number of dots in a square with nn rows and nn columns; a number of this form is called a perfect square.
The nn-th square number is:
Square Number Formula
Sn=n2S_n = n^2
Learn more about this formula: Square Number Formula →
So 1616, 2525 and 3636 are square numbers; 1212, 2020 and 3030 are not.
The square numbers form a sequence: 1, 4, 9, 16, 25, …
The name reflects the geometric construction: arrange n2n^2 dots in a square grid with nn rows and nn columns. The first square numbers are:
Definition
1,4,9,16,25,36,49,64,81,100,…1, 4, 9, 16, 25, 36, 49, 64, 81, 100, \ldots
For a large number, building squares is impractical; the square root does the test in one step.
A positive integer is called a perfect square if it equals n2n^2 for some integer nn. Testing whether a number is a perfect square amounts to checking whether its square root is an integer.
To list square numbers or test whether a number is a perfect square, use the square numbers calculator.
How each square grows from the one before — by an odd number of dots — is shown in recursive form and odd number sums.
The rest of the page covers the recursive form and odd number sums, the properties of square numbers, the sum of squares, and the connection to triangular numbers.

Square Number Notation

Notation

Square Number Notation

A subscripted letter for the n-th square, a rule that adds the next odd number, and sigma for the running total.
The subscript as position, the brace form and sigma are set out at sequence notation; n2n^2 is read as in exponent notation.
Sn=n2S_n = n^2
S sub n — the n-th square number
One term, not a sum: S5=25S_5 = 25. The page's letter for 1,4,9,16,…1, 4, 9, 16, \ldots, the dots in an n×nn \times n grid.
CasesStarts at S1=1S_1 = 1. A perfect square is any integer equal to some n2n^2; 00 counts when the list starts at S0S_0.
Also writtenn2n^2 alone — most texts skip the letter.
Same glyph elsewhereOn the arithmetic and geometric pages SnS_n is a partial sum. Here it is a single term.
Sn=Sn−1+(2n−1)S_n = S_{n-1} + (2n - 1)
each square is the one before plus the n-th odd number
Going from (n−1)2(n-1)^2 to n2n^2 adds an L-shaped border of 2n−12n - 1 dots. Unrolled, the rule says the first nn odd numbers add up to n2n^2 (section 2).
CasesNeeds the anchor S1=1S_1 = 1.
Do not confuse2n+12n + 1 — the odd number after the n-th one; it builds Sn+1S_{n+1} from SnS_n.
∑k=1nk2\sum_{k=1}^{n} k^2
the sum of k squared, for k from one to n
Square each term, then add: 1+4+⋯+n2=n(n+1)(2n+1)61 + 4 + \cdots + n^2 = \frac{n(n+1)(2n+1)}{6} (section 4).
Also written12+22+⋯+n21^2 + 2^2 + \cdots + n^2; ∑k2\sum k^2 with the bounds understood.
Do not confuse(∑k=1nk)2\left(\sum_{k=1}^{n} k\right)^2 — add first, then square. For n=5n = 5: 5555 against 225225.
DownloadPNG2×PDF
Notation · Cheat sheet
Sequence Notation at a Glance
The marks from the notation cards across the sequence pages: how each is read and what it means. Every group links to the full card on its page.
Sequences
ana_n
a sub n
The term in place nn; the subscript is a position.
a1,a2,a3,…a_1, a_2, a_3, \ldots
a one, a two, a three, and so on
The terms listed in order; the dots need a stated rule.
{an}n=1∞\{a_n\}_{n=1}^{\infty}
the sequence a sub n
The whole sequence as one object.
Arithmetic sequences
an+1=an+da_{n+1} = a_n + d
next term is this term plus d
The recurrence; dd is the common difference, a1a_1 the start.
∑k=1nak\textstyle\sum_{k=1}^{n} a_k
sum of a sub k, k from 1 to n
Sigma: the sum SnS_n of the first nn terms.
Geometric sequences
rr
r, the common ratio
The factor from each term to the next: an=a1rn−1a_n = a_1 r^{n-1}.
SnS_n
S sub n
Sum of the first nn terms; nn counts terms.
SS
S, the infinite sum
Equals a1/(1−r)a_1 / (1 - r), only when ∣r∣<1|r| < 1.
GG
G, the geometric mean
G=abG = \sqrt{ab}, the middle value of a,G,ba, G, b.
Fibonacci sequence
FnF_n
F sub n
The nn-th Fibonacci number, counted from F1=F2=1F_1 = F_2 = 1.
ϕ,  ψ\phi, \; \psi
phi and psi
The roots of x2=x+1x^2 = x + 1, about 1.6181.618 and −0.618-0.618.
LnL_n
L sub n
Lucas numbers: the same rule, started at 1,31, 3.
Harmonic sequences
an=1/bna_n = 1/b_n
a sub n is one over b sub n
bnb_n is the arithmetic sequence underneath.
HnH_n
H sub n
The harmonic number 1+12+⋯+1n1 + \frac{1}{2} + \cdots + \frac{1}{n}.
HH
H, the harmonic mean
For two numbers, H=2aba+bH = \frac{2ab}{a + b}.
Triangular numbers
TnT_n
T sub n
The nn-th triangular number, n(n+1)2\frac{n(n+1)}{2}.
Tn=Tn−1+nT_n = T_{n-1} + n
the one before plus a row of n
The recurrence, from T1=1T_1 = 1.
(n+12)\binom{n+1}{2}
n plus one choose two
The same number, counted as pairs.
Square numbersThis page
Sn=n2S_n = n^2
S sub n on this page
The nn-th square: one term, not a sum.
Sn=Sn−1+2n−1S_n = S_{n-1} + 2n - 1
the one before plus the next odd number
The recurrence, from S1=1S_1 = 1.
∑k=1nk2\textstyle\sum_{k=1}^{n} k^2
sum of k squared
Square each term first, then add.
Prime numbers
pp
p, a prime
The letter promises a prime.
p1,…,pkp_1, \ldots, p_k
p sub one to p sub k
A list of primes, or the primes of one number.
π(n)\pi(n)
pi of n
How many primes are at most nn.
Same letter, different job
SnS_nA sum of nn terms on the arithmetic and geometric pages; a single square on the square numbers page.
HnH_n vs HHWith a subscript, a sum of reciprocals; without one, a mean.
π(n)\pi(n) vs π\piA count of primes, not the circle constant.
{an}\{a_n\}An ordered sequence, not a set: terms keep their order and may repeat.
Sequence Notation at a Glance·/algebra/sequencesLearn Math Class

Recursive Form and Odd Number Sums

Each square number can be built from the previous one by adding an L-shaped border — a gnomon — containing 2n−12n - 1 dots:

Recursive Form (Square Numbers)
S1=1,Sn=Sn−1+(2n−1)S_1 = 1, \quad S_n = S_{n-1} + (2n - 1)
Learn more about this formula: Recursive Form (Square Numbers) →

The increments 1,3,5,7,9,…1, 3, 5, 7, 9, \ldots are the odd numbers, which form an arithmetic sequence with first term 11 and common difference 22. Summing all the increments gives:

Sum of First n Odd Numbers
n2=1+3+5+⋯+(2n−1)n^2 = 1 + 3 + 5 + \cdots + (2n - 1)
Learn more about this formula: Sum of First n Odd Numbers →


Pitfall: Using the last odd number as n
Taking 1+3+5+⋯+991 + 3 + 5 + \cdots + 99 as 992=980199^2 = 9801 squares the last term. The last term is 2n−1=992n - 1 = 99, so n=50n = 50 and the sum is 502=250050^2 = 2500.

Every perfect square is a sum of consecutive odd numbers starting from 11. This identity can be verified by the arithmetic series formula: the sum of the first nn odd numbers is n2(1+(2n−1))=n2\frac{n}{2}(1 + (2n-1)) = n^2.

The difference between consecutive squares is always odd: Sn−Sn−1=2n−1S_n - S_{n-1} = 2n - 1. This means no two consecutive integers are both perfect squares — there is always an odd gap between neighboring squares, and that gap widens as nn grows.
A 5 by 5 square of dots built from L-shaped layers of 1, 3, 5, 7, 9 dotsnn1234561234561+3+5+7+91 + 3 + 5 + 7 + 9 = 25: each L-shaped layer adds the next odd number
A square built from odd layers

A 5 × 5 square of dots, coloured by layer. The corner dot is 1. Each next layer is an L-shape wrapped around the square before it: 3 dots to make 2 × 2, then 5, 7 and 9. A layer around an (n − 1) × (n − 1) square needs n dots along the top and n − 1 down the side, which is 2n − 1, so 1 + 3 + 5 + 7 + 9 = 5² = 25.

The layers grow by 2 each time, so the gaps between consecutive squares are the odd numbers.

Properties

Perfect squares have distinctive divisibility patterns. A perfect square modulo 44 is always 00 or 11 — never 22 or 33. This is because even numbers squared give multiples of 44, and odd numbers squared give 11 more than a multiple of 44. Similarly, a perfect square modulo 33 is always 00 or 11 — never 22.

The last digit of a perfect square can only be 0,1,4,5,6,0, 1, 4, 5, 6, or 99. Any integer ending in 2,3,7,2, 3, 7, or 88 is immediately ruled out as a perfect square, without computing any square root.

Pitfall: Reading the last-digit test backwards
Calling 2626 a square because it ends in 66: 52=255^2 = 25 and 62=366^2 = 36, so 2626 lies between two squares. A good last digit only keeps a number possible; N\sqrt{N} must still be a whole number.

Both tests are quick filters: each looks at one feature of the number, its remainder or its last digit, and needs no root at all. A number that fails either one is ruled out at once, which makes them useful for large candidates such as 7,3827{,}382, which ends in 22, or 15,64315{,}643, which leaves remainder 33 on division by 44.

Consecutive perfect squares are always coprime: gcd⁡(n2,(n+1)2)=1\gcd(n^2, (n+1)^2) = 1, because gcd⁡(n,n+1)=1\gcd(n, n+1) = 1 and the GCD of squares equals the square of the GCD.

The number of perfect squares up to NN is ⌊N⌋\lfloor \sqrt{N} \rfloor. Perfect squares become increasingly sparse — the gap between n2n^2 and (n+1)2(n+1)^2 is 2n+12n + 1, which grows linearly. Among the first 100100 integers, 1010 are perfect squares; among the first 10,00010{,}000, only 100100 are.

Fact: Odd tens digits only before a 6
A perfect square with an odd tens digit always ends in 66, as 1616, 196196 and 576576 do, and every square ending in 66 has an odd tens digit. Squares leave only the remainders 0,1,4,5,90, 1, 4, 5, 9 and 1616 on division by 2020, and only 1616 has an odd tens digit.

The last two digits are restricted as well. A number and the number 5050 larger have squares ending in the same two digits, since (n+50)2=n2+100n+2500(n + 50)^2 = n^2 + 100n + 2500, and the same holds for nn and 50−n50 - n. The squares of 00 to 2525 therefore produce every possible ending, and only 2222 of the 100100 endings from 0000 to 9999 ever occur: 00,01,04,09,16,21,24,25,29,36,…00, 01, 04, 09, 16, 21, 24, 25, 29, 36, \ldots

Sum of Squares

The sum of the first nn square numbers is:

Sum of Squares
∑k=1nk2=n(n+1)(2n+1)6\sum_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6}
Learn more about this formula: Sum of Squares →


One derivation uses the telescoping identity (k+1)3−k3=3k2+3k+1(k+1)^3 - k^3 = 3k^2 + 3k + 1. Summing both sides from k=1k = 1 to nn:

Sum of Squares
(n+1)3−1=3∑k2+3∑k+n(n+1)^3 - 1 = 3\sum k^2 + 3\sum k + n

Substituting ∑k=n(n+1)2\sum k = \frac{n(n+1)}{2} and solving for ∑k2\sum k^2 gives the result.

For example, the sum of the first 55 squares is 1+4+9+16+25=551 + 4 + 9 + 16 + 25 = 55, which matches 5⋅6⋅116=55\frac{5 \cdot 6 \cdot 11}{6} = 55.

Pitfall: Squaring the sum instead of summing the squares
Writing 12+22+⋯+521^2 + 2^2 + \cdots + 5^2 as (1+2+⋯+5)2(1 + 2 + \cdots + 5)^2 gives 152=22515^2 = 225. Each term is squared separately: 1+4+9+16+25=551 + 4 + 9 + 16 + 25 = 55.

This formula contrasts with the triangular number sum ∑k=n(n+1)2\sum k = \frac{n(n+1)}{2}, which is quadratic in nn. The sum of squares is cubic — each additional term contributes a squared value, making the total grow faster.

Stacked cannonballs show the sum in solid form. A square pyramid of balls with an n×nn \times n layer at the bottom, an (n−1)×(n−1)(n-1) \times (n-1) layer above it, and so on up to a single ball at the top holds exactly 12+22+⋯+n21^2 + 2^2 + \cdots + n^2 balls: 5555 for a pyramid 55 layers high and 385385 for one 1010 layers high.

Fact: A pyramid that flattens into a square
A pyramid of cannonballs 2424 layers high holds 24⋅25⋅496=100⋅49=702\frac{24 \cdot 25 \cdot 49}{6} = 100 \cdot 49 = 70^2 balls, so it can be laid out flat as a 70×7070 \times 70 square. Apart from a single ball, it is the only such pyramid: G. N. Watson proved this in 1918.

For large nn the count is close to n33\frac{n^3}{3}, because the formula expands to n(n+1)(2n+1)6=n33+n22+n6\frac{n(n+1)(2n+1)}{6} = \frac{n^3}{3} + \frac{n^2}{2} + \frac{n}{6}. The leading term n33\frac{n^3}{3} is the volume of a solid pyramid with an n×nn \times n base and height nn, and the balls overshoot it by n22+n6\frac{n^2}{2} + \frac{n}{6}: for n=10n = 10, that is 385−33313=5123385 - 333\frac{1}{3} = 51\frac{2}{3}.

Summing squares raises the degree by one: the first nn squares add up to a cubic in nn, close to n33\frac{n^3}{3}.

Connections to Triangular Numbers

Square numbers and triangular numbers are linked by the identity:

Connections to Triangular Numbers
Sn=Tn+Tn−1S_n = T_n + T_{n-1}

Every perfect square is the sum of two consecutive triangular numbers. For n=4n = 4: 16=T4+T3=10+616 = T_4 + T_3 = 10 + 6. The geometric proof is direct: cut a square grid of n2n^2 dots along the diagonal staircase. The dots on and above the staircase form a triangle with nn rows (TnT_n dots), and the dots below form a triangle with n−1n-1 rows (Tn−1T_{n-1} dots).

Another connection runs through Pythagorean triples — sets of three positive integers (a,b,c)(a, b, c) satisfying a2+b2=c2a^2 + b^2 = c^2. Every primitive Pythagorean triple, with its legs in either order, can be generated by choosing integers m>n>0m > n > 0 with gcd⁡(m,n)=1\gcd(m, n) = 1 and opposite parity, then setting:

Pythagorean Triple Generator
a=m2−n2,b=2mn,c=m2+n2a = m^2 - n^2, \quad b = 2mn, \quad c = m^2 + n^2
Learn more about this formula: Pythagorean Triple Generator →


The triple (3,4,5)(3, 4, 5) comes from m=2,n=1m = 2, n = 1; the triple (5,12,13)(5, 12, 13) from m=3,n=2m = 3, n = 2. Pythagorean triples connect square numbers to geometry — each triple defines a right triangle with integer side lengths.
A 4 by 4 square of dots cut along the staircase into 10 dots and 6 dotsnn1234512345blue: T₄ = 1 + 2 + 3 + 4 = 10amber: T₃ = 64² = 16 = T₄ + T₃ = 10 + 6: a square is two staircase triangles
A square cut into two triangles

The section’s n = 4. The dashed staircase line splits the 4 × 4 square of dots in two. The blue dots on and above it come in columns of 4, 3, 2 and 1, the triangular number T₄ = 10. The amber dots below come in columns of 3, 2 and 1, which is T₃ = 6. Together they fill the square: 10 + 6 = 16.

The same cut works for every n: n² = Tₙ + Tₙ₋₁.

Common Pitfalls

Three mistakes come up again and again with square numbers. Each one is marked where it happens in the sections above; here each is worked through in full, with the wrong and the right working side by side.
DownloadPNG2×PDF
1Using the last odd number as n
In the identity n2=1+3+5+⋯+(2n−1)n^2 = 1 + 3 + 5 + \cdots + (2n - 1), nn is the number of odd terms, not the last term. Squaring the last odd number counts far too many terms.
Start
1+3+5+⋯+991 + 3 + 5 + \cdots + 99
Wrong turn
Error here
=992=9801= 99^2 = 9801
Right path
The last term is 2n−12n - 1, so 2n−1=992n - 1 = 99 gives n=50n = 50 terms.
=502=2500= 50^2 = 2500
Why it happensIn the sum of the first nn positive integers the last term is nn itself, and that habit carries over to the odd numbers, where the last term is 2n−12n - 1.
How to checkTry a short case. 1+3+5=9=321 + 3 + 5 = 9 = 3^2, with 33 terms, while squaring the last term would give 52=255^2 = 25. Also, 5050 terms that are each below 100100 add up to less than 50⋅100=500050 \cdot 100 = 5000, so 98019801 is too large.
2Reading the last-digit test backwards
The last-digit rule and the remainder rules say what a square cannot look like. They are used the other way round, as if every number with an allowed last digit or remainder were a square.
Wrong turn
Error here
2626 ends in 66, an allowed last digit, and 1313 leaves remainder 11 on division by 44, an allowed remainder, so both are taken to be perfect squares.
Right path
The tests can only rule numbers out. To confirm a square, its square root must be a whole number:
52=25<26<36=62,5^2 = 25 < 26 < 36 = 6^2,

32=9<13<16=423^2 = 9 < 13 < 16 = 4^2
So neither 2626 nor 1313 is a perfect square. A number that passes, such as 676676, needs the same check: 262=67626^2 = 676, so it is a square.
Why it happensThe tests are quick and look like a full answer, and the difference between "every square ends in 0,1,4,5,60, 1, 4, 5, 6 or 99" and "every number ending in those digits is a square" is easy to miss.
How to checkFind the two consecutive squares around the number. If it equals neither, it is not a square, whatever its last digit. Most numbers pass the digit test: 66 of the 1010 possible last digits are allowed, while only 1010 of the first 100100 integers are squares.
3Squaring the sum instead of summing the squares
The sum ∑k2\sum k^2 is read as (∑k)2\left(\sum k\right)^2: the numbers are added first and the total is squared, instead of each number being squared first.
Start
12+22+32+42+521^2 + 2^2 + 3^2 + 4^2 + 5^2
Wrong turn
Error here
=(1+2+3+4+5)2=152=225= (1 + 2 + 3 + 4 + 5)^2 = 15^2 = 225
Right path
=1+4+9+16+25=55= 1 + 4 + 9 + 16 + 25 = 55
Which matches 5⋅6⋅116=55\frac{5 \cdot 6 \cdot 11}{6} = 55.
Why it happensSquaring looks as if it should pass through a sum, the way multiplication by a constant does. It does not: (a+b)2=a2+2ab+b2(a + b)^2 = a^2 + 2ab + b^2, and the cross terms 2ab2ab are what make 225225 so much larger than 5555.
How to checkUse n=2n = 2. 12+22=51^2 + 2^2 = 5, while (1+2)2=9(1 + 2)^2 = 9. The formula gives 2⋅3⋅56=5\frac{2 \cdot 3 \cdot 5}{6} = 5.
Common pitfalls with square numbers·/algebra/sequences/square-numbersLearn Math Class
Two of the slips put the wrong number into a formula: the sum of the first nn odd numbers is n2n^2, where nn counts the terms rather than naming the last one, and a sum of squares is not the square of a sum. The third reads a test that can only rule numbers out as if it could confirm them. A short case such as 1+3+5=91 + 3 + 5 = 9, or the two squares on either side of a number, settles each of them.

Square Numbers FAQ

How can you tell at a glance that a number is not a perfect square?

+
Check its last digit. Perfect squares can only end in 0,1,4,5,60, 1, 4, 5, 6 or 99, so anything ending in 2,3,72, 3, 7 or 88 is ruled out immediately without computing a root. A second test uses remainders: a perfect square is always 00 or 11 modulo 44, never 22 or 33, which catches 2626 even though it ends in 66.Read more →

How rare are perfect squares among the integers?

+
They thin out steadily, because the gap between n2n^2 and (n+1)2(n+1)^2 is 2n+12n + 1 and grows without limit. The count up to NN is ⌊N⌋\lfloor \sqrt{N} \rfloor, so ten of the first hundred integers are perfect squares, but only a hundred of the first ten thousand. The proportion keeps falling.Read more →

Can two consecutive perfect squares share a common factor?

+
Never, other than 11. Consecutive squares are always coprime: gcd⁡(n2,(n+1)2)=1\gcd(n^2, (n+1)^2) = 1. It follows from the fact that nn and n+1n + 1 are themselves coprime, since consecutive integers share no factor, and squaring preserves that because the GCD of squares is the square of the GCD.Read more →

Can a perfect square end in any two digits?

+
No: only 2222 of the 100100 endings from 0000 to 9999 ever occur. Since (n+50)2=n2+100n+2500(n + 50)^2 = n^2 + 100n + 2500, a number and the number 5050 larger have squares with the same last two digits, and so do nn and 50−n50 - n, so the squares of 00 to 2525 already show every ending. One pattern stands out: a square with an odd tens digit always ends in 66, as 1616, 196196 and 576576 do.Read more →

Can a pyramid of cannonballs be laid out as a square?

+
Only one can, apart from a single ball. A square pyramid nn layers high holds 12+22+⋯+n2=n(n+1)(2n+1)61^2 + 2^2 + \cdots + n^2 = \frac{n(n+1)(2n+1)}{6} balls, and for n=24n = 24 that is 24⋅25⋅496=4900=702\frac{24 \cdot 25 \cdot 49}{6} = 4900 = 70^2, so the pyramid flattens into a 70×7070 \times 70 square. G. N. Watson proved in 1918 that no other height above 11 works.Read more →

Does m2−n2m^2 - n^2, 2mn2mn, m2+n2m^2 + n^2 give every Pythagorean triple?

+
No, only the primitive ones, when m>n>0m > n > 0 are coprime and of opposite parity: m=2m = 2, n=1n = 1 gives (3,4,5)(3, 4, 5) and m=3m = 3, n=2n = 2 gives (5,12,13)(5, 12, 13). Multiples can be missed. The triple (9,12,15)(9, 12, 15) is 3⋅(3,4,5)3 \cdot (3, 4, 5), yet no mm and nn produce it, since 1515 is not a sum of two squares. Multiplying a primitive triple by a whole number kk covers the rest.Read more →