No Square Number Ever Ends in 2, 3, 7 or 8
Gepubliceerd op 16-11-2026 · 3 min leestijd · Dagelijkse calculators
Antonio Delgado — Redacteur tradities en tijdverdrijf bij OneKitly
Symboliek · Kalenders
Getoetst aan 2 bronnen
Square the digits 0 to 9 and the last digits that come out are 0, 1, 4, 9, 6, 5, 6, 9, 4 and 1 — six distinct values, with 2, 3, 7 and 8 never appearing. Since the last digit of a square depends only on the last digit of the number, no square of any size can end in one of those four. That gives an instant test: 33 856 might be a square and 33 857 certainly is not, decided by looking at a single character. Forty per cent of numbers are eliminated for free, before any arithmetic starts.
1, 4, 9, 16, 25, 36, 49, 64, 81, 100 — the last digits cycle through six values and never the other four. It is a free test for a perfect square.
The same idea in other bases
Working in base sixteen, a square can only end in 0, 1, 4 or 9, which throws away three quarters of the candidates instead of two fifths. Programmers checking for perfect squares exploit exactly that, testing the low bits before doing any real work. The general fact is that squares occupy a shrinking fraction of the residues as the modulus grows, which is why a chain of quick modular tests eliminates almost everything and leaves a tiny number of genuine candidates to check properly.
Why the pattern is symmetric
Numbers ending in 2 and in 8 give squares ending in 4, and the pair 3 and 7 both give 9. The reason is that 8 is ten minus two, and squaring it produces a hundred minus forty plus four — everything but the four is a multiple of ten and invisible in the last digit. That symmetry pairs the digits around 5 and is why only six results appear rather than ten. It also means a square's last digit can never tell you the last digit of its root, only narrow it to two possibilities.
| Ends in | Square ends in | Example |
|---|---|---|
| 2 or 8 | 4 | 144, 324 |
| 3 or 7 | 9 | 169, 289 |
| 5 | 5 | 25, 225 |
Veelgestelde vragen
- Does the same work for the digit sum?
- Yes, and it catches different impostors. Reduce a number by repeatedly adding its digits and a perfect square always lands on 1, 4, 7 or 9. Combining the two tests — last digit and digit root — throws out about three quarters of all numbers with two glances and no division. Neither test can confirm a square, only refuse one, which is the usual shape of a cheap check: fast at saying no and silent about yes.
- How do I check a candidate properly?
- Take the square root, round to the nearest whole number and square it again. If you get back what you started with, it was a square. That is three operations and it is exact for anything a normal calculator handles, though very large integers need care because floating-point roots drift once the number exceeds what the format can represent exactly. Beyond about sixteen digits, use integer arithmetic and a bisection or Newton step instead.
Artikelen die je misschien interesseren
Alle gidsen →Vergelijkbare tools
Bronnen
Een fout in dit artikel gezien?