Software engineer interview questions shared by candidates
implement sqrt without using math libray
I think exp and ln still require a Math library. How about using Newton's method to find the root of f(x) = x^2 - a, where x is the solution (the sought square root) and where a is the number for which you want to find the square root?
I would have implemented either Taylor or MacLaurin series, centered at an integer number that is closest to the number that you want to find the square root for, such that the square root of this integer is clean. So if you wanted to find the square root of 8.5, I would centre the series at 9 (sqrt(9) = 3), then compute the series at that point. I'd probably choose between 8 and 10 terms, as that is what is used in any scientific calculator.
See Interview Questions for Similar Jobs
- Software Developer
- Senior Software Engineer
- Software Development Engineer
- Senior Software Developer
- Software Engineer III
- Software Development Engineer II
- Java Developer
- Business Analyst
- Software Engineer I
- Junior Software Engineer