Shortest way to check perfect Square? [duplicate]

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)