One way to compute the square root of a real number x is to use the Babylonian algorithm. You begin by guessing that the square root of x is x / 2. The steps of this algorithm are as follows:
guess = x / 2
previousGuess = 0
Repeat until guess is within 1% of previousGuess
{
r = x / guess
previousGuess = guess
guess = (guess + r) / 2
}
Write a program that reads a number and computes its square root by using the Babylonian algorithm. Display your results to two decimal places. You should get an accurate answer even for large numbers.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here