Integer Square Root Calculation
Given a positive integer 'N', compute its square root and return it. If 'N' is not a perfect square, then return the floor value of sqrt(N).
Example:
Input:
N = 25
N = 20
N = 2
Output:
5
4
1
Explanation:
For 'N' = 25, the output is 5 as 5*5 = 25. For 'N' = 20, the output is 4 because the floor value of the square root of 20 is 4. Similarly, for 'N' = 2, the floor value of the square root is 1.
Constraints:
1 <= T <= 5
0 <= N <= 1016
- Time Limit: 1 sec.
AnswerBot
9d
Calculate the square root of a positive integer and return the floor value if not a perfect square.
Use the sqrt() function to calculate the square root of the given integer.
If the square root is not a...read more
Help your peers!
Add answer anonymously...
Top NetApp Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app