Пример #1
0
assertEqual(getBigSubtract("111", "100"), "11");
assertEqual(getBigSubtract("14", "14"), "0");
assertEqual(getBigSubtract("15", "14"), "1");
assertEqual(getBigSubtract("14", "15"), "ERROR");
assertEqual(getBigSubtract("1400000000", "1500000000"), "ERROR");
assertEqual(getBigSubtract("1400000000000", "1500000000000"), "ERROR");
assertEqual(getBigSubtract("1500000000001", "1400000000002"), "99999999999");
assertEqual(getBigSubtract("1400000000000000", "1500000000000000"), "ERROR");
assertEqual(getBigSubtract("1500000000001001", "1400000000002003"), "99999999998998");
assertEqual(getBigAdd("19", "1"), "20");
assertEqual(getBigAdd("1900000000000000000001", "100000000000000000078"), "2000000000000000000079");
assertEqual(getBigAdd("1900000000000000000001000001", "10000000000000000007800009"), "1910000000000000000008800010");
assertEqual(getBigMultiply("1000", "1000"), "1000000");
assertEqual(getBigMultiply("1000000", "1000000"), "1000000000000");
assertEqual(getBigMultiply("10000000", "10000000"), "100000000000000");
assertEqual(getBigMultiply("100000000", "100000000"), "10000000000000000");
assertEqual(getBigMultiply("1000000001", "1000000001"), "1000000002000000001");
assertEqual(getBigMultiply("10000000001", "10000000001"), "100000000020000000001");
assertEqual(getBigMultiply("22", "22"), "484");
assertEqual(getBigDivide("14", "2"), "7");
assertEqual(getBigDivide("15", "2"), "7");
assertEqual(getBigDivide("16", "2"), "8");
assertEqual(getBigDivide("16000000000000000028", "222222222229998"), "71999");
assertEqual(getGreaterThan("10", "2"), TRUE);
assertEqual(getGreaterThan("2", "10"), FALSE);
assertEqual(isThisPrime('15730', '15727'), FALSE);
assertEqual(getPreviousPrime('104761'), "104759");
assertEqual(getNextPrime("104759"), "104761");
assertEqual(getNextPrime(getBigVariable('last-prime')), "LAST_PRIME");
assertEqual(getBigSquareRoot("10000"), "100");
assertEqual(getBigSquareRoot("10000000000"), "100000");
Пример #2
0
include_once 'functions.inc';
#########################################################################################
# This is the daemon worker file that runs in the background on the server as a service #
#########################################################################################
echo "Starting worker\n";
global $VERBOSE;
for ($x = 0; $x < 20000; $x) {
    if ($VERBOSE) {
        echo "Identifying last prime\n";
    }
    $last_prime = getBigVariable('last-prime');
    if ($VERBOSE) {
        echo "Last prime was:" . $last_prime . "\n";
        echo "Identifying last tested\n";
    }
    $last_tested = getBigVariable('last-tested');
    if ($VERBOSE) {
        echo "Last tested was:" . $last_tested . "\n";
    }
    ## Enter main rouine.
    $test = getBigAdd($last_tested, "1");
    echo "Now testing:" . $test . "\n";
    $result = isThisPrime($test, $last_prime);
    if ($result == FALSE) {
        echo "Not prime\n";
        notPrime($test);
    } else {
        echo "Prime found: {$test} \n";
        foundPrime($test);
    }
}