Square root of a number - Newtons method

# Square root of a number - Newtons method

print("\n\nSquare root of a number - Newtons method")
num1 = int(input("Enter a number : "))
x = num1//2

while (True):
    y = (x + num1/x) / 2
    if (y == x):
        print("Square root of", num1, "is", round(y,4))
        break
    x = y

No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu