Skip to content

Instantly share code, notes, and snippets.

@a-eid
Created March 21, 2017 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-eid/c7b778da4fdd1af4fbf8fc5e0db47233 to your computer and use it in GitHub Desktop.
Save a-eid/c7b778da4fdd1af4fbf8fc5e0db47233 to your computer and use it in GitHub Desktop.
newton method sqrt recursive
// square root of x in range of e .. g could be much better guessed .
function sq(x , e , g ){
g = g || x / 2
if(Math.abs( g * g - x ) < e )
return g
else
return sq( x , e , ( g + x / g ) / 2 )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment