```
public bool IsPerfectSquare(int num) {
//newton raphson f(x1)=x0-(f(x0)/fprime(x0))
// f(x)=x^2-n
if(num<=0){return false;}
int xk=num;
int xk1=((xk+(num/xk))>>1);
while(Math.Abs(xk1-xk)>1)
{
xk=xk1;
xk1=((xk+(num/xk))>>1);
}
return ((xk1*xk1)==num);
}
```