In: Computer Science
Your problem statement is not very clear to me. The statement "h / k sqrt(n)" is not very clear. Could you explain the significance of h, k and n here?
For time being, I am providing the code to calculate sqrt(n) in C. Feel free to reach out in case of any queries.
CODE
#include <stdio.h>
int floorSqrt(int x)
{
if (x == 0 || x == 1)
return x;
int start = 1, end = x, ans;
while (start <= end)
{
int mid = (start + end) / 2;
if (mid*mid == x)
return mid;
if (mid*mid < x)
{
start = mid + 1;
ans = mid;
}
else
end = mid-1;
}
return ans;
}
int main()
{
int x = 11;
printf("Square root of 11 = %d", floorSqrt(x));
return 0;
}