Help for this page

Select Code to Download


  1. or download this
    canis [shmem] /home/shmem > time perl -e 'my $iters = 100_000; my $run
    +s = 6; for my $sides (qw{1 2 3 4 6 8 10 20 100}) { printf "%-5s", "D$
    +sides:"; for (1 .. $runs) { my $tot = 0; for (1 .. $iters) { $tot += 
    +int(rand $sides)+1; } print " ", $tot/$iters; } print "\n"; } '
    D1:   1 1 1 1 1 1
    ...
    
    Perl may be copied only under the terms of either the Artistic License
    + or the
    GNU General Public License, which may be found in the Perl 5.0 source 
    +kit.
    
  2. or download this
    canis [shmem] /home/shmem > time perl4 -e '$iters = 100_000; $runs = 6
    +; for $sides (1,2,3,4,6,8,10,20,100) { printf "%-5s", "D$sides:"; for
    + (1 .. $runs) { $tot = 0; for (1 .. $iters) { $tot += int(rand $sides
    +)+1; } print " ", $tot/$iters; } print "\n"; }'
    D1:   1 1 1 1 1 1
    ...
    
    Perl may be copied only under the terms of either the Artistic License
    + or the
    GNU General Public License, which may be found in the Perl 4.0 source 
    +kit.