note 24917 deleted from function.pow by victor
| From: | victor@php.net | Date: | Tue, 16 Aug 2005 12:04:43 +0000 |
| Subject: | note 24917 deleted from function.pow by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93729@lists.php.net to get a copy of this message | ||
Note Submitter: b1svkg54 at glen-net dot ca
----
A function I made to calculate pi using Wallis' Formula and pow(); I hope it is of help.
Rimtech
#phphelp on DalNet IRC
<?
function calculatepi($terms)
{
$pi = 0;
$k = 1;
while ($terms != 0)
{
$terms--;
$pi = $pi / 4;
$pi = $pi + (1/(((2*$k)-1)*(-1)*(pow(-1,$k))));
$pi = $pi * 4;
$k++;
}
return $pi;
}
?>