<?php
$start = microtime(true);
function bcfact($n) {
$factorial = 1;
for ($i = 1; $i <= $n; $i++) {
$factorial = bcmul($factorial, $i);}
return $factorial;
}
function bcpi($precision)
{
$num = 0;$k = 0;
bcscale($precision+3);
$limit = ($precision+3)/14;
$sqrt=bcsqrt('640320',$precision+3);
while($k < $limit)
{
$num = bcadd($num, bcdiv(bcmul(bcadd('13591409',bcmul('545140134', $k)),bcmul(bcpow(-1, $k), bcfact(6*$k))),bcmul(bcmul(bcpow('640320',3*$k+1),$sqrt), bcmul(bcfact(3*$k), bcpow(bcfact($k),3)))));
++$k;
}
return bcdiv(1,(bcmul(12,($num))),$precision);
}
echo bcpi(min($_GET['i'],1200)??100);
$end = microtime(true);
echo '<br>'. $end - $start;
?>