Mega Code Archive
Approximating a square root
Approximating a square root
$precision) or ($guess_squared - $target < - $precision))
{
print("Current guess: $guess is the square root of $target
");
$guess = ($guess + ($target / $guess)) / 2;
$guess_squared = $guess * $guess;
}
print("$guess squared = $guess_squared
");
?>