我的主要問題是: 這是很多循環?Pi幫助Php(質量循環)
while ($decimals < 50000 and $remainder != "0") {
$number = floor($remainder/$currentdivider); //Always round down! 10/3 =3, 10/7 = 1
$remainder = $remainder%$currentdivider; // 10%3 =1, 10%1
$thisnumber = $thisnumber . $number;
$remainder = $remainder . 0; //10
$decimals += 1;
}
還是我可以適應更多? - 沒有服務器崩潰/滯後。
我只是想知道, 也有一個更有效的方式做到上述? (例如finidng指出1/3 = 0.3〜50000小數。)
最後:
我這樣做了PI公式(1 - 1/3 1/5 + - 1/7等)一,
而我想知道是否有更好的。 (在PHP) 我發現一個在4秒內發現pi到2000。
但那不是我想要的。我想會聚接近丕
所以每次刷新,用戶可以查看它越來越近了無窮級數...
但OBV。使用上述公式收斂需要花費時間。
是否有任何其他'循環'像Pi公式(在PHP中可行),收斂速度更快?
非常感謝......
注意,你不會得到足夠的精度得到比PI的幾個小數位數以上,只要您使用PHP的基本的算術運算符。但是,您可以使用BC數學函數:http://www.php.net/manual/en/ref.bc.php – 2010-06-16 12:50:33
可能的重複[哪一個是找到Pi的最佳公式?](http:// stackoverflow。com/questions/3045020/which-the-the-the-best-formula-to-find-pi) – interjay 2010-06-16 19:00:31
@interjay由於某種原因,可能重複的鏈接被破壞 – JAL 2010-06-16 20:20:54