I have tried to compute this algorithm with python and it doesn't seem to work:
lt = False
x = 5
g = 2
while lt == False:
if g*g > (x-0.1) and g*g < (5.1):
lt = True
print(g+"IS THE SQUARE ROOT")
else:
g = (g + x/g)/2
print(g)
In the else loop, I printed g to see the outcome of my algorithm in each loop because I was experiencing slow computation previously and wanted to see what the problem was, and now print(g) seems to consistently be returning 2. I'm new to python and the problem is probably staring me in the face but I can't seem to figure it, any help would be much appreciated!