function Kereses($elso, $szo, &$array, $arrayNum, $log, $also) { $n = 1; for ($i = (int) $szo[$elso[0]] + 1; $i < 10; $i++) { $szo[$elso[0]] = $i; $szo[$elso[1]] = $i; $szo[$elso[2]] = $i; $n += LinearSearch($array, $szo, $arrayNum, $log, $also); } return $n; }
//----------------------------------------------------------------------------- $prim2[] = 2; $prim2[] = 3; $darab = 2; $i = 6; while ($i - 1 < 100000) { if (Prim($prim2, $i - 1)) { $prim2[] = $i - 1; $darab++; } if (Prim($prim2, $i + 1)) { $prim2[] = $i + 1; $darab++; } $i += 6; } $log = ceil(log($darab, 2)); $b = 0; $max_darab = 0; while ($prim2[$b] < 1000) { $n = 0; while (LinearSearch($prim2, $n * $n + -777 * $n + $prim2[$b], $darab, $log, 0)) { $n++; } if ($n > $max_darab) { $max_darab = $n; $max_ert = $prim2[$b]; } $b++; } echo $max_darab . " " . $max_ert;