1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 10:59:02 +01:00

Translating..:

This commit is contained in:
danogentili 2016-06-26 14:58:44 +02:00
commit 1fb44d1d83

View File

@ -14,7 +14,15 @@ function everynth($array, $n) {
}
return $result;
}
function array_merge_ignore_keys($array1, $array2) {
if(count($array1) == count($array2)) {
$i = -1;
foreach ($array1 as $key => $val){
$array1[$key] = $array2[$i++];
}
} else return null;
return $array1;
}
function primesbelow($N) {
$correction = (($N % 6) > 1);
$N = [0 => $N, 1 => ($N - 1), 2 => ($N + 4), 3 => ($N + 3), 4 => ($N + 2), 5 => ($N + 1) ][($N % 6) ];
@ -23,6 +31,7 @@ function primesbelow($N) {
foreach (pyjslib_range((floor(pyjslib_int(pow($N, 0.5)) / 3) + 1)) as $i) {
if ($sieve[$i]) {
$k = ((3 * $i) + 1) | 1;
<<<<<<< HEAD
$sieve = array_merge($sieve, array_merge(everynth(array_splice($sieve, floor($k*$k / 3)), 2*$k), (array_fill(0, floor(((floor($N / 6) - floor(($k * $k) / 6)) - 1) / $k) + 1, false))));
$sieve = array_merge(
$sieve, array_merge(
@ -62,6 +71,10 @@ function primesbelow($N) {
)
)
);
=======
$sieve = array_merge($sieve, array_merge_ignore_keys(everynth(array_splice($sieve, floor($k*$k / 3)), 2*$k), ([false] * ((((($N / 6) - (($k * $k) / 6)) - 1) / $k) + 1))));
$sieve = array_merge($sieve, array_merge_ignore_keys(everynth(array_splice($sieve, floor((k*k + 4*k - 2*k*(i%2)) / 3)), 2*$k), ([false] * ((((($N / 6) - (((($k * $k) + (4 * $k)) - ((2 * $k) * ($i % 2))) / 6)) - 1) / $k) + 1))));
>>>>>>> 3b4b6d5362ad99cd9cb9e2d11b22cbf32fe2cccf
}
}
return ([2, 3] + array_map(function ($i, $sieve) { if($sieve[$i]) return (3 * $i + 1) | 1; }, pyjslib_range(1, (($N / 3) - $correction)), $sieve));