note 79587 added to function.sqrt
| From: | xxcoderz at gmail dot com | Date: | Tue, 04 Dec 2007 17:52:47 +0000 |
| Subject: | note 79587 added to function.sqrt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132805@lists.php.net to get a copy of this message | ||
the output of these function is the same of php sqrt function:-
function nsqr($num)
{
//minus root
//imagine number
if($num<0)
{
return "Minus root !";
}
$n=1;
//I use newton method to find the root
while($sqr==false)
{
$new=($n+($num/$n))/2;
if($prev_val==$new)
{
$sqr=true;
return $new;
}
$prev_val=$new;
$n=$new;
}
}
the use of these function like ..
<?
//nsqr
nsqr(2);
echo"<br>and sqrt buildin php function :<br>";
//sqrt
sqrt(2);
?>
Ahmad Shukr.
----
Server IP: 69.147.83.197
Probable Submitter: 213.6.20.148
----
Manual Page -- http://www.php.net/manual/en/function.sqrt.php
Edit -- https://master.php.net/note/edit/79587
Del: integrated -- https://master.php.net/note/delete/79587/integrated
Del: useless -- https://master.php.net/note/delete/79587/useless
Del: bad code -- https://master.php.net/note/delete/79587/bad+code
Del: spam -- https://master.php.net/note/delete/79587/spam
Del: non-english -- https://master.php.net/note/delete/79587/non-english
Del: in docs -- https://master.php.net/note/delete/79587/in+docs
Del: other reasons-- https://master.php.net/note/delete/79587
Reject -- https://master.php.net/note/reject/79587
Search -- https://master.php.net/manage/user-notes.php