Pregunta de entrevista de Bloomberg

How to compute square root of integer with only add, sub, div and mult

Respuestas de entrevistas

Anónimo

4 mar 2014

f(x)=sqrt(x); 1. Find the integer (n) whose square (x0) is closest to x, e.g: n=sqrt(x0); 2. Use taylor expansion: f(x) = f(x0) + f'(x0)(x-x0) = n + 1/2n*(x-n^2); Verify: x=59; x0=64; n=8; f(59) = 8+1/16*(59-64) =7.6875

3

Anónimo

23 sep 2012

let y(x) = sqrt(x) then guess a value guessY now calculate mean(guessY+x/guessY) which is new guessY keep doing until the relative error < epsilon