In mathematics, a square number, sometimes also called a perfect square, is a positive integer that can be written as the square of some other integer. So for example, 9 is a square number since it can be written as 3×3. By convention, the first square number is 1. The number m is a square number if and only if one can arrange m points in a square:

1:

+               x

4:

x +             x x
+ +             x x

9:

x x +           x x x
x x +           x x x
+ + +           x x x

16:

x x x +         x x x x
x x x +         x x x x
x x x +         x x x x
+ + + +         x x x x

25:

x x x x +       x x x x x 
x x x x +       x x x x x 
x x x x +       x x x x x 
x x x x +       x x x x x 
+ + + + +       x x x x x 

The formula for the nth square number is n2. This is also equal to the sum of the first n odd numbers, as can be seen in the above pictures, where a square results from the previous one by adding an odd number of points (marked as '+'). So for example, 52 = 25 = 1 + 3 + 5 + 7 + 9.

A square number is also the sum of two consecutive triangular numbers.

Lagrange's four-square theorem states that any positive integer can be written as the sum of at most 4 perfect squares. 3 squares are not sufficient for numbers of the form 4k(8l + 7). This is generalized by Waring's problem.

A positive integer that has no perfect square divisors except 1 is called square-free.

See also: