A farmer has x square metres of land. He wants to fence the biggest square plot that fits inside it, and the side of the plot must be a whole number of metres.
Find the longest whole-number side r such that r * r <= x, and return r. This is the square root of x, rounded down.
You may not use any built-in power or root function or operator, such as pow, sqrt or **.
Examples
Example 1:
Input: x = 26
Output: 5
Explanation: A side of 5 uses 25 square metres. A side of 6 would need 36, which is too much. So the answer is 5.
Example 2:
Input: x = 35
Output: 5
Explanation: The root of 35 is about 5.916, and rounding down gives 5.
Example 3:
Input: x = 100
Output: 10
Explanation: 10 x 10 is exactly 100.