3v4l.org

run code in 300+ PHP versions simultaneously
<?php function bcfact($n) { return ($n == 0 || $n== 1) ? 1 : bcmul($n,bcfact($n-1)); } function bcpi($precision) { $num = 0;$k = 0; bcscale($precision+3); $limit = ($precision+3)/14; 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),bcsqrt('640320')), bcmul(bcfact(3*$k), bcpow(bcfact($k),3))))); ++$k; } return bcdiv(1,(bcmul(12,($num))),$precision); } echo bcpi(1000);
Output for 7.1.10, 7.2.29 - 7.2.33, 7.3.0, 7.3.16 - 7.3.31, 7.4.3, 7.4.6 - 7.4.16, 7.4.20 - 7.4.23, 8.0.0 - 8.0.5, 8.0.8, 8.0.11, 8.0.14 - 8.0.15, 8.0.19, 8.0.26, 8.0.29, 8.1.19, 8.1.28, 8.2.3, 8.2.16 - 8.2.18, 8.3.3 - 8.3.6

Process exited with code 137.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.2.0, 7.3.12, 7.4.0, 7.4.4 - 7.4.5, 7.4.19, 7.4.24 - 7.4.32, 8.0.6 - 8.0.7, 8.0.9, 8.0.16 - 8.0.18, 8.0.20 - 8.0.25, 8.0.27 - 8.0.28, 8.0.30, 8.1.0 - 8.1.18, 8.1.20 - 8.1.27, 8.2.0 - 8.2.2, 8.2.4 - 8.2.15, 8.3.0 - 8.3.2
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989
Output for 7.3.32 - 7.3.33, 7.4.33, 8.0.13
Fatal error: Uncaught Error: Call to undefined function bcscale() in /in/TMvTk:9 Stack trace: #0 /in/TMvTk(19): bcpi(1000) #1 {main} thrown in /in/TMvTk on line 9
Process exited with code 255.
Output for 8.0.10, 8.0.12
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989
Process exited with code 137.
Output for 5.5.0 - 5.5.26
Fatal error: Call to undefined function bcscale() in /in/TMvTk on line 9
Process exited with code 255.

preferences:
237.91 ms | 401 KiB | 293 Q