#!/usr/bin/perl -w use strict; my ($nr1, $nr2, $nr3); my @passes; for (1..1_000_000) { #print $_ .": \n"; $nr1 = int ( rand(100) ); my $i = 0; do { $nr2 = int ( rand(100) ); $i++; } while($nr1+$nr2 > 99); $nr3 = 100-($nr1+$nr2); #print "Durchlaeufe: ". $i ."\n"; push @passes, $i; #print "$nr1 + $nr2 + $nr3 = " . ($nr1+$nr2+$nr3) ."\n"; } my $average; $average += $_ for @passes; $average /= scalar @passes; print "\nDurchschnittl. Anzahl d. Durchlaeufe: " .$average;