A puzzle to begin
Imagine a row of lockers. Each one is opened or shut once for every factor of its number. At the end, only a few are left standing open. Which ones? The answer depends on a hidden property of factors, and that property picks out the square numbers. We will start with this puzzle. Then we will gather what squares look like: their last digits, their zeros at the end, whether they are odd or even, and the way they grow by adding odd numbers.
The locker puzzle
Sixty lockers stand closed, numbered to . Sixty people pass by. Person opens every locker. Person toggles every second locker, which means closing it if it is open and opening it if it is closed. Person toggles every third locker, and so on, until person toggles only locker . Which lockers are open at the end? Have a guess before you read on.
Take locker . It is touched by persons , which are its factors. That is six times, so it ends up closed. A locker ends up open only when it is toggled an odd number of times, that is, when its number has an odd number of factors.
Now, factors come in pairs that multiply to give the number. For the pairs are . So the count is even, unless one pair uses the same number twice, like for . And that happens only when the number is some number multiplied by itself.
So the open lockers are . These are the square numbers up to . Here is a bonus: the lockers touched exactly twice, by person and by their own number, are the primes.

Squares
We write as and read it as " squared". The name comes from a square of side , which holds small unit squares. The squares of natural numbers are called perfect squares: You can square fractions, decimals and negative numbers too: , , .
What the last digit tells you
Squaring the digits to gives last digits . So a perfect square always ends in or . It never ends in or .
Be careful, because this test works in one direction only. ends in , so it cannot be a square. ends in , but that proves nothing. In fact is not a square either, since and .
Here are some handy patterns. Numbers ending in or have squares ending in . Numbers ending in or have squares ending in . Numbers ending in have squares ending in .
Zeros and parity
, . Do you see the pattern? A number ending in zeros has a square ending in zeros. So a square never ends in an odd number of zeros, and that is why is not a square.
An even number squared is even, and an odd number squared is odd. In other words, a square is always odd or even just like the number it came from.
Squares grow by odd numbers
Look at the gaps. Squares next to each other differ by odd numbers that come one after another, because . Turn this around and you get a beautiful fact:
The picture tells the whole story. An square grows into an square when you add an L-shaped border of unit squares. That drawing is a complete proof, without a single word.

Example 1. Given , find . Just add the th odd number, which is . So .
Example 2. Is a square? Keep subtracting in turn: . It never lands on , so the answer is no. Now try : . It reaches zero after seven subtractions, so .
Between two squares
Between and lie numbers that are not squares. For example, between and there are sixteen numbers, and between and there are sixty.
This means squares get rarer as you go up. There are ten of them up to , but only four between and (), and three between and . The largest square below is .
Squares and triangular numbers
Triangular numbers count dots in a triangle: Add any two that sit next to each other, and you get a square: , , . The picture shows why: two staircases fit together to make a square.

Practice
- Which of these cannot be perfect squares, judged by their last digit alone? , , , , , .
- Which of , , , end in ?
- Given , find by adding the right odd number.
- Given , write as .
- Use repeated subtraction of odd numbers to decide whether and are squares.
- How many numbers lie between and ? Between and ?
- How many perfect squares lie between and ? Between and ?
- The th and th triangular numbers are and ; their sum is which square? What about the th and th, and ?
- In a row of lockers with the same rule, which stay open, and which are touched exactly twice?
Answers
Show answers
- (ends in ), (), (). The others pass the test but only and are squares; ends in three zeros, so it is not.
- and (last digits and ).
- nd odd number is : .
- , since ; .
- : eight steps, . : not a square.
- ; .
- : two. : one.
- ; .
- Open: . Touched twice: .