0) && (intval($_GET['runs']) <= 1000000)) { $runs = intval($_GET['runs']); } $time = date ('Ymd-His'); $filename = 'v2-log-' . $time . '.txt'; $resultfile = 'v2-results.txt'; while (ob_get_level()) { ob_end_clean(); } $strecke = 1.0; $no = 0; $yes = 0; for ($i = 1; $i <= $runs; $i++) { ### a---b-----c------d $ad = 1; $faktor1 = mt_rand(0, mt_getrandmax()); $faktor2 = mt_rand(0, mt_getrandmax()); ### Teilpunkte zufällig bestimmen $t1 = 1/mt_getrandmax() * $faktor1; ## * $ad $t2 = 1/mt_getrandmax() * $faktor2; ## * $ad ### Teilpunkte sortieren $b = min($t1,$t2); $c = max($t1,$t2); $ab = $b; $bc = $c - $b; $cd = 1 - $c; ### keine Teilstecke länger/gleich 50%? if ( max($ab, $bc, $cd) >= 0.5 ) { $result = "$i \t kein Dreieeck möglich, $ab \t $bc \t $cd" . PHP_EOL; $no ++; } else { $result = "$i \t Dreieck mit $ab \t $bc \t $cd möglich" . PHP_EOL; $yes++; } file_put_contents($filename, $result, FILE_APPEND); ### aller 1000 Versuche ein Lebenszeichen geben if ($i % 1000 == 0) { echo "$i\r\n"; flush(); flush(); } } $ergebnis = 'Versuche = ' . $runs . PHP_EOL . 'Fehlanzeigen = ' . $no . PHP_EOL . 'Wahrscheinlichkeit = ' . (1-($no/$i)) . PHP_EOL; file_put_contents($filename, PHP_EOL . $ergebnis, FILE_APPEND); file_put_contents($resultfile, PHP_EOL . $time .', ' . $ergebnis, FILE_APPEND); echo "\r\n$ergebnis"; ?>