/ Published in: PHP
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
<?php
/**
cobra90nj@cobra90nj:~/Scrivania$ time php ll.php
104760
real 0m46.014s
user 0m42.267s
sys 0m0.056s
*/
function isPrime($num)
{
if ($num == 2 || $num == 3) { return 1; }
if (!($num%2) || $num<1) { return 0; }
for ($n = 3; $n <= $num/2; $n += 2) {
if (!($num%$n)) {
return 0;
}
}
return 1;
}
$obb = 1;
$ispr = 4;
while ($obb < 10001) {
if (isPrime($ispr)) {
$obb++;
$ispr++;
}
else {
$ispr++;
}
}
echo $ispr;
Comments
 Subscribe to comments
                    Subscribe to comments
                
                