diff --git a/lib/danog/PrimeModule.php b/lib/danog/PrimeModule.php index 85354ca..d16386d 100644 --- a/lib/danog/PrimeModule.php +++ b/lib/danog/PrimeModule.php @@ -218,8 +218,11 @@ class PrimeModule if ($res[0] == false) { return false; } - while (array_product($res) !== $what) { - $res[] = self::native_single_cpp($what / array_product($res)); + while (($product = array_product($res)) !== $what) { + if ($product == 0) { + return false; + } + $res[] = self::native_single_cpp($what / $product); } return $res; diff --git a/tests/testing.php b/tests/testing.php index b0e4b64..0d08833 100755 --- a/tests/testing.php +++ b/tests/testing.php @@ -94,6 +94,7 @@ function gen_payload() return chr(10).str_repeat(chr(0), 8).\danog\PHP\Struct::pack(' 0, 'python_alt' => 0, 'wolfram' => 0, 'native' => 0, 'native_cpp' => 0]; $tg = fsockopen('tcp://149.154.167.51:443'); @@ -110,6 +111,7 @@ fclose($tg); foreach ($medium as $type => $total) { echo $type.': total time '.$total.', medium time '.($total / $tot).PHP_EOL; } + echo PHP_EOL.'------------------- SMALL MULTIPLE FACTOR TESTS -------------------'.PHP_EOL; $GLOBALS['medium'] = ['python' => 0, 'python_alt' => 0, 'wolfram' => 0, 'native' => 0, 'native_cpp' => 0];