Skip to content

Instantly share code, notes, and snippets.

@hector117
Created March 30, 2017 23:01
Show Gist options
  • Save hector117/9defc2636f27e9c26135952ebd743871 to your computer and use it in GitHub Desktop.
Save hector117/9defc2636f27e9c26135952ebd743871 to your computer and use it in GitHub Desktop.
def Babilonia(n):
a = n
b = 0
while b > (n-.00001) or b < (n+.00001):
a = n/a
b = a*a
if b > (n-.00001) and b < (n+.00001):
return a
else:
a = (n/a+a)/2
b = a*a
return a
#main program below
print("WSQ-10")
n = float(input("Ingresa un número "))
f = Babilonia(n)
print("La raíz cuadrada de ",n, "es aproximadamente de ",f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment