Skip to content

Instantly share code, notes, and snippets.

@ramalho
Created March 10, 2011 16:31
Show Gist options
  • Save ramalho/864410 to your computer and use it in GitHub Desktop.
Save ramalho/864410 to your computer and use it in GitHub Desktop.
Raiz quadrada pelo método de Newton
def media(x, y):
return float(x + y)/2
def raizq(x):
''' raiz quadrada pelo metodo de Newton '''
chute = 1.0
while abs(chute * chute - x) >= 0.0001:
chute = media(chute, float(x)/chute)
return chute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment