Beispiel #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");
Beispiel #2
0
print "<span>";
if ($page != 1) {
    $prev = $page - 1;
    print "<a href='index.php?page={$prev}'>previous page</a><br />";
}
if ($page > 10) {
    $pre10 = $page - 10;
    print "<a href='index.php?page={$pre10}'>-10</a><br />";
}
if ($page < $pages) {
    $next = $page + 1;
    print "<a href='index.php?page={$next}'>next page</a><br />";
}
if ($page < $pages - 10) {
    $nex10 = $page + 10;
    print "<a href='index.php?page={$nex10}'>+10</a>";
}
print "</span><br /><br />";
print "This site knows about " . number_format($prime_count, 0, ",", ",") . " primes<br />";
print "The biggest prime known by this site is " . number_format($last_prime, 0, ",", ",") . "<br />";
print "The last prime was found:" . date('D d M Y H:i:s', getBigVariable('prime-time')) . "<br /><br />";
printPage($page, TRUE);
$cache_page = getBigVariable('cache-page');
if ((int) $cache_page == $page - 1 && $page < $pages) {
    // Try to make a cache.
    $content = printPage($page, FALSE);
    $filename = 'pages/' . ensureFileSize($page) . ".html";
    file_put_contents($filename, $content);
    setBigVariable('cache-page', $page);
}
exit;
Beispiel #3
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);
    }
}