Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WSQ13
#Gilberto Rogel García a01631071 Babylonian method
def bmethod(n):
x=n
y=0
while(x!= y):
y=x
#print ("y",y)
x=(n/x + x)/2
#print ("x",x)
return x
n= float(input("Give me a number to get its square root using the babylonian method:"))
if(n==0):
print("The square root is:", n)
elif(n<0):
print("Error")
else:
res = bmethod(n)
print ("The square root of your number is:", res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.