0) && (intval($_GET['runs']) <= 1000000)) { $runs = intval($_GET['runs']); } $time = date ('Ymd-His'); $filename = 'log-' . $time . '.txt'; $resultfile = 'results.txt'; while (ob_get_level()) { ob_end_clean(); } $strecke = 1.0; $no = 0; for ($i = 1; $i <= $runs; $i++) { $faktor = mt_rand(0, mt_getrandmax()); $result = ''; $ab = 1/mt_getrandmax() * $faktor; if ($ab < 0.5) { $faktor = mt_rand(0, mt_getrandmax()); $bc = (1-$ab)/mt_getrandmax() * $faktor; $cd = 1 - $ab - $bc; $result = "Dreieck, ab = $ab \t bc = $bc \t cd = $cd" . PHP_EOL; if ($bc >= 0.5 || $cd >= 0.5) { $no++; $result = "kein Dreieck, ab = $ab \t bc = $bc \t cd = $cd" . PHP_EOL; } } else { $result = "kein Dreieck, ab = $ab" . PHP_EOL; $no++; } 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 . PHP_EOL, FILE_APPEND); echo "\r\n$ergebnis"; ?>