SEARCH HOME
Math CentralQuandaries & Queries

search

Question from Manick, a student:
Hello Sir
I have a question. how to find whether a given integer is a perfect square or not?

Manick,

This depends upon what information and computing resources you are assuming. For many purposes the answer is just "find the square root and see if it is a whole number". This can be fairly efficient even if you are computing with paper & pencil, if you know algorithms for finding square roots. Realistically, find the square root till you get down to the decimals, square, and see if you get your number back.

You can tell a number is NOT a perfect square if it ends in 2,3,7 or 8. (More advanced: if it ends in two digits that do not end the square of any 2-digit number. As (10A + B)2 = [100 A2 +] 20A + B2, the tens digit must differ by an even number from that of the square of a one-digit number. Base 10, two squares of one-digit numbers share a last digit occur only when the one-digit numbers are B and (10-B) so the squares (mod 100) are B2 and -20B + B2 - thus tens digits always have the same parity. All this means that if the tens digit differs by an odd number from that of _any_ square with the right ones digit the number cannot be square. So, as 16 is a square, no number ending in 06,26,..., or 86 can be square. This simple test rules out 70% of numbers based on their last two digits.

If you have the prime factorization of a number, it is a square if every factor appears an even number of times. If you know how many factors it has (including itself and 1) it is a square if that factor count is odd.

Good Hunting!
RD

 

About Math Central
 

 


Math Central is supported by the University of Regina and The Pacific Institute for the Mathematical Sciences.
Quandaries & Queries page Home page University of Regina PIMS