Example #1
0
function getNumberOfDivisors($dividend)
{
    $factorization = factorize($dividend);
    //print_r($factorization);
    //echo "\n";
    $divisorsNumber = 1;
    while (list($k, $v) = each($factorization)) {
        $divisorsNumber *= $v + 1;
    }
    return $divisorsNumber;
}
Example #2
0
function factorize($number)
{
    $factors = array();
    if (isPrime($number)) {
        return array($number => 1);
    }
    $ceil = sqrt($number);
    $factor = 2;
    while ($factor <= $ceil) {
        if ($number % $factor == 0) {
            $factors = addFactorizations($factors, factorize($factor));
            $factors = addFactorizations($factors, factorize($number / $factor));
            break;
        }
        $factor++;
    }
    return $factors;
}
Example #3
0
function factorize(&$target, &$primes, &$factor)
{
    $multiplier = 2;
    $factored = true;
    $sieve = range($primes[count($primes) - 1] + 1, $factor);
    for ($i = 0; $i < count($primes); $i++) {
        if ($target % $primes[$i] == 0) {
            $target = $target / $primes[$i];
            if (isPrime($target)) {
                result(6857, $target);
                die;
            }
        }
        if ($i == count($primes) - 1) {
            $factored = false;
            $factor *= $multiplier;
            $primes = reducer($factor, $sieve, $primes, $target);
            factorize($target, $primes, $factor);
        }
    }
}
Example #4
0
}
if (preg_match("#--verbose#", @implode(" ", $argv))) {
    $GLOBALS["VERBOSE"] = true;
}
if (preg_match("#--repos#", @implode(" ", $argv))) {
    $GLOBALS["REPOS"] = true;
}
if (preg_match("#--force#", @implode(" ", $argv))) {
    $GLOBALS["FORCE"] = true;
}
if ($argv[1] == "--cross-packages") {
    crossroads_package();
    exit;
}
if ($argv[1] == "--factorize") {
    factorize($argv[2]);
    exit;
}
if ($argv[1] == "--serialize") {
    serialize_tests();
    exit;
}
if ($argv[1] == "--latests") {
    latests();
    exit;
}
if ($argv[1] == "--error-txt") {
    error_txt();
    exit;
}
if ($argv[1] == "--c-icap") {