6 ms·
haha the amusing thing is that he himself likely only looked up the newton-raphson method ten minutes before phoning you. sadly that is the case for many of the
by furburger 17y ago
haha the amusing thing is that he himself likely only looked up the newton-raphson method ten minutes before phoning you. sadly that is the case for many of these mensa-test mental masturbation questions...if you had asked your interviewer the day before, they too would have drawn a blank.
you would think it would suffice to just tell him, yeah, i am aware that the newton-raphson method exists, and what it is supposed to do.
- adr 17y agoYou can also use binary search to approximate the square root of a number.
- furburger 17y agowell the point is, and i think this is the original poster's point...questions like this are not relevant to what facebook is doing, and even if it is, its the kind of thing you look up.
- albertni 17y agoIn Facebook's defense (I have no affiliation with FB, and in general am not a big fan of them), they probably weren't looking for somebody to whip out Newton's method, but rather just binary search. Everyone who says "this question is completely irrelevant" isn't completely right. This question would be completely irrelevant if they were exclusively looking for a "fancy" square root finding technique. However, binary search is a pretty basic algorithm - the trick here is to recognize that such a basic algorithm can be applied to a seemingly unrelated problem. If Facebook is testing to see if people can connect different parts of their knowledge (square root function is strictly increasing, something that everyone knows to be true at least intuitively, combined with the fact that binary search can then be used in such a situation), then it's a reasonable question to ask. Maybe not for a front-end developer though.
- patio11 17y agoYou can also use a lookup table, an AJAX call to a square root web service, using the canvas and drawing appropriate geometric shapes then measuring, or, if you have a bit of free time, implementing code which has commercial value, accepting money for it, and then going to Radio Shack and buying yourself a calculator with a square root key. But personally, yeah, I'd use Math.sqrt.