long long int floorSqrt(long long int x)
{
// Your code goes here
long long int l=0 , r = x, ans;
while(l<=r){
long long int mid= (int)(l+r)/2;
long long int m = mid*mid;
if( m == x){
return mid;
}
if(mid>= (int)x/mid){
r = mid -1;
}
if( mid <=(int)x/mid){
l = mid+1;
ans = mid;
}
}
return ans;
}
this is the function made to calculate the square root of a given number X , using binary search to complete it in o(log n) i am using GFG code compiler , using a gcc5.4