RosettaCodeData/Task/Percolation-Mean-run-density/Perl-6/percolation-mean-run-density.pl6
2015-02-20 09:02:09 -05:00

10 lines
240 B
Raku

sub R($n, $p) { [+] ((rand < $p) xx $n).squish }
say 't= ', constant t = 100;
for .1, .3 ... .9 -> $p {
say "p= $p, K(p)= {$p*(1-$p)}";
for 10, 100, 1000 -> $n {
printf " R(%6d, p)= %f\n", $n, t R/ [+] R($n, $p)/$n xx t
}
}