Description
Given a non-negative integer x, return the square root of x rounded down to the nearest integer. Use Newton's method for calculation.
Examples
Input:
x = 8Output:
2Explanation:
√8 = 2.82..., rounded down to 2.
Input:
x = 0Output:
0Explanation:
√0 = 0 exactly, so the result is 0. This tests the edge case of the minimum possible input.
Input:
x = 15Output:
3Explanation:
√15 = 3.872..., rounded down to 3. This demonstrates rounding down when the square root is not a perfect integer.
Constraints
- •
0 ≤ x ≤ 2³¹ - 1