Why Can a Perfect Square End Only in 0, 1, 4, 5, 6, or 9?
At a glance
- 1. Check the final digit
Write the integer as 10q + r, where r is its last digit.
- 2. Square modulo 10
Since (10q + r)² and r² have the same remainder modulo 10, only r² matters.
- 3. List the possibilities
Squaring the ten possible final digits gives only 0, 1, 4, 5, 6, and 9 as final digits.
- 4. Use the test carefully
A different final digit rules out a perfect square, but an allowed final digit does not prove a number is square.
A quick way to rule out a number as a perfect square is to inspect its final digit. In ordinary base-10 notation, no integer square ends in 2, 3, 7, or 8. The reason is that the last digit of a square is determined entirely by the last digit of the integer being squared.
Why only the last digit matters
Since , it is enough to consider nonnegative integers. Any nonnegative integer can be written as , where is an integer and is one of . The remainder is the last digit of . Squaring gives
The first two terms are multiples of 10, so they cannot change the final digit. Equivalently, modulo 10,
Thus, to find every possible final digit of a square, it is enough to square the ten possible final digits of an integer.
| Last digit of | Last digit of |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
| 4 | 6 |
| 5 | 5 |
| 6 | 6 |
| 7 | 9 |
| 8 | 4 |
| 9 | 1 |
The only resulting digits are and . Therefore, if an integer ends in or , it cannot be a perfect square.
A direct proof by cases
You can also group the possible last digits into pairs that give the same square ending:
- If ends in 0, then ends in 0.
- If ends in 1 or 9, then ends in 1.
- If ends in 2 or 8, then ends in 4.
- If ends in 3 or 7, then ends in 9.
- If ends in 4 or 6, then ends in 6.
- If ends in 5, then ends in 5.
These cases cover every possible integer last digit and establish the claim. The argument works for negative integers too: a negative integer still has one of the same ten final digits, and its square is nonnegative.
Worked examples
Consider . The number 137 ends in 7, so its square must end in 9. Indeed,
For another example, 24 ends in 4, so its square must end in 6. In fact,
The test is especially useful for rejecting candidates without calculating a square root. For example, 1,238 cannot be a perfect square because it ends in 8. There is no need to test nearby squares.
The test is necessary, not sufficient
A perfect square must end in one of the six listed digits, but not every number with one of those endings is a square. For instance, 21 ends in 1, an allowed square ending, but it is not a perfect square: .
So the last-digit test has a one-way use: an ending of 2, 3, 7, or 8 proves that a number is not a square; an ending of 0, 1, 4, 5, 6, or 9 merely means the test does not rule it out. Other methods, such as checking whether the integer square root is an integer, are needed to decide whether it actually is a square.
Common mistakes
- Treating the list as a characterization. The list gives possible endings, not a guarantee that every number with one of those endings is square.
- Using the wrong base. This exact list applies to the usual base-10 notation. In another base, the possible final digits are determined by squares modulo that base and may differ.
- Checking more than the last digit when only this test is needed. The final digit of depends only on the final digit of , because every other term in is divisible by 10.
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.