close all; clear; clc

S = input("Enter a number: ");

x = S;
k = 0;

while abs(x*x - S) >= 0.001
    x = (x + S / x) / 2;
    k = k + 1;
    fprintf("current guess: %f\n", x)
end

fprintf("final value: %f\n", x)
fprintf("took %d steps\n", k)