Perl Pi Snippit


$aantal=100000;
for ($i=1;$i<=$aantal;$i++){
$x = rand();
$y = rand();
# print "$i:($x,$y)\n";
$r=$x*$x+$y*$y;
if ($r < 1) {$k++;}
}
print "pi = ".$k*4/$aantal;