Skip to content

Instantly share code, notes, and snippets.

@git2samus
Created May 22, 2012 19:43
Show Gist options
  • Select an option

  • Save git2samus/2771172 to your computer and use it in GitHub Desktop.

Select an option

Save git2samus/2771172 to your computer and use it in GitHub Desktop.
function newton_square_root(x, e) {
var guess = 1;
while (Math.abs(x - guess*guess) > e)
guess -= (guess*guess-x) / (2*guess);
return guess;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment