note 79587 deleted from function.sqrt by felipe

From: Date: Sat, 15 Dec 2007 15:58:31 +0000
Subject: note 79587 deleted from function.sqrt by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133590@lists.php.net to get a copy of this message
Note Submitter: xxcoderz at gmail dot com Reason: 1 ---- 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.

« previous php.notes (#133590) next »