```
public static int sqrt (int a){
int low =0;
int high = a;
while (low <= high){
int mid = (low+high)/2;
if (mid*mid == a)
return mid;
if (mid*mid > a){
high = mid-1;
}
else {
low = mid + 1;
}
}
return high;
}
```