Possible Duplicate:
What's a good algorithm to determine if an input is a perfect square?
I want Shortest and Simplest way to Check a number is perfect square in C#
Some of Perfect Squares:
1, 4, 9, 16, 25, 36, 49, 64, 81, 100, ......
Probably checking if the square root of the number has any decimal part, or if it is a whole number.
Implementationwise, I would consider something like this:
double result = Math.Sqrt(numberToCheck);
bool isSquare = result%1 == 0;
isSquare
should now be true
for all squares, and false
for all others.