Пример #1
0
    }
    switch ($p) {
        case 1:
            break;
        case 89:
            $total++;
            $x[] = $n;
            return $total;
            break;
        default:
            echo "error!";
            break;
    }
    //print_r($x);
}
$max = pow(9, 2) * 7;
$limit = 10000000;
$total = 0;
$x = array();
for ($i = 1; $i <= $limit; $i++) {
    $sum = square_chain($i, $total, $x);
}
echo "Sum is {$total}";
//////////////////////////////////////////////////////////////////////
// End of execution time calculation
$time_end = microtime(true);
$execution_time = $time_end - $time_start;
//total execution time
/////////////////////////////////////////////////////////////////////
//Below Outputs the execution time in seconds
echo '<br /><br /><b>Total Execution Time:</b> ' . $execution_time . ' seconds';
Пример #2
0
        $count = count($digits);
        $sum = 0;
        for ($i = 0; $i < $count; $i++) {
            $sum += pow($digits[$i], 2);
        }
        $n = $sum;
    }
    if ($n == 89) {
        //$list[]= $q;
        //$list[]= strrev($q);
        $total += 1;
        return $total;
    } elseif ($n == 1) {
        return $total;
    }
}
$limit = 10000000;
$total = 0;
for ($i = 1; $i < $limit; $i++) {
    square_chain($i, $total);
}
//print_r($list);
echo "Total is {$total}";
//////////////////////////////////////////////////////////////////////
// End of execution time calculation
$time_end = microtime(true);
$execution_time = $time_end - $time_start;
//total execution time
/////////////////////////////////////////////////////////////////////
//Below Outputs the execution time in seconds
echo '<br /><br /><b>Total Execution Time:</b> ' . $execution_time . ' seconds';