PHP Programing language

How can Find for any number square root using while Loop
Previous Home Next
<html>
<head>
<title>Find a square root for any number</title>
</head>
<body>
<?php
$number = 41;
$g=1.0;
$pre= 0.0000001;
$g_squared = $g * $g;
while (($g_squared - $number > $pre) or ($g_squared - $number < - $pre))
{
  $g = ($g + ($number / $g)) / 2;
  $g_squared = $g * $g;
}
print("$g squared = $g_squared<BR>");
?>
</body>
</html>
output:
6.4031242374328 squared = 41
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: