Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Monte-Carlo-methods/PHP/monte-carlo-methods.php
Normal file
10
Task/Monte-Carlo-methods/PHP/monte-carlo-methods.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?
|
||||
$loop = 1000000; # loop to 1,000,000
|
||||
$count = 0;
|
||||
for ($i=0; $i<$loop; $i++) {
|
||||
$x = rand() / getrandmax();
|
||||
$y = rand() / getrandmax();
|
||||
if(($x*$x) + ($y*$y)<=1) $count++;
|
||||
}
|
||||
echo "loop=".number_format($loop).", count=".number_format($count).", pi=".($count/$loop*4);
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue