Skip to content

Instantly share code, notes, and snippets.

@ctlllll
Created October 10, 2017 07:18
Show Gist options
  • Save ctlllll/5013f4e7fdd7a2715ce0417bedcfc26e to your computer and use it in GitHub Desktop.
Save ctlllll/5013f4e7fdd7a2715ce0417bedcfc26e to your computer and use it in GitHub Desktop.
Naive Sqrt Algorithm
def Sqrt(x):
r1=x
r2=x+1
while abs(r1-r2)>1e-10:
r1=r2
r2=(r2+x/r2)/2
return r2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment