Mgccl
新手上路

初级会员
UID 67583
精华
0
积分 5
帖子 3
金钱 5 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2005-12-29
状态 离线
|
[广告]: q
m
PHP find Pi
<?php function bcpi($precision){ $limit = ceil(log($precision)/log(2))-1; bcscale($precision+6); $a = 1; $b = bcdiv(1,bcsqrt(2)); $t = 1/4; $p = 1; while($n < $limit){ $x = bcdiv(bcadd($a,$b),2); $y = bcsqrt(bcmul($a, $b)); $t = bcsub($t, bcmul($p,bcpow(bcsub($a,$x),2))); $a = $x; $b = $y; $p = bcmul(2,$p); ++$n; } return bcdiv(bcpow(bcadd($a, $b),2),bcmul(4,$t),$precision); } ?> This is the pi calculator I have made to calculate pi. It can calculate pi to 2000th decimal in 8 seconds, one of the fastest around.
|
|