Пример #1
0
include_once 'functions.inc';
assertEqual("3", getBigSubtract("6", "3"));
assertEqual(getBigSubtract("110", "100"), "10");
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");
Пример #2
0
<?php

include_once 'functions.inc';
date_default_timezone_set('Europe/London');
$row = 1;
$last_prime = getBigVariable('last-prime');
$prime_count = getBigVariable('prime-count');
$pages = getBigAdd(getBigDivide($prime_count, 10000), "1");
if (isset($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = 1;
}
print "<h2>Page {$page} of {$pages}</h2>\n";
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>";
}
Пример #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);
    }
}