Compute the largest integer r such that r * r <= n (the floor of the square root of n).
Input format
One line: a non-negative integer n.
Output format
One line: floor(sqrt(n)).
Constraints
- 0 <= n <= 1000000000000000000
Compute the largest integer r such that r * r <= n (the floor of the square root of n).
One line: a non-negative integer n.
One line: floor(sqrt(n)).
Example 1
Input
8
Expected
2
Explanation
2*2=4 <= 8 but 3*3=9 > 8, so floor(sqrt(8)) = 2.
Example 2
Input
16
Expected
4
Explanation
4*4=16, so the answer is 4.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →