Questions d'entretien de Engineer partagées par les candidats
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.
You have 9 marbles which are all the same weight, except for one which is slightly heavier than the others. You also have an old?style balance, which allows you to weigh two piles of marbles to see which one is heavier (or if they are of equal weight). What is the fewest number of weighings that you can make which will tell you which marble is the heavier one ?