xxxxxxxxxx
# Python program to find if x is a
# perfect square.
import math
def isPerfectSquare(x):
#if x >= 0,
if(x >= 0):
sr = int(math.sqrt(x))
# sqrt function returns floating value so we have to convert it into integer
#return boolean T/F
return ((sr*sr) == x)
return false
# Driver code
x = 2502
if (isPerfectSquare(x)):
print("Yes")
else:
print("No")
# This code is contributed
# by Anant Agarwal.
xxxxxxxxxx
public static bool IsPerfectSquare(int number)
{
if (number < 0)
{
return false;
}
var sqrt = (int)Math.Sqrt(number);
return sqrt * sqrt == number;
}