- 1 < prime numbers < 100,000
- 100,000 < prime numbers < 200,000
- 200,000 < prime numbers < 300,000
- 300,000 < prime numbers < 400,000
- 400,000 < prime numbers < 500,000
- 500,000 < prime numbers < 600,000
- 600,000 < prime numbers < 700,000
- 700,000 < prime numbers < 800,000
- 800,000 < prime numbers < 900,000
- 900,000 < prime numbers < 1,000,000
Download all prime numbers < 1,000,000 (gzipped, comma delimited) here.
PHP:
<?
function is_prime($i)
{
if($i % 2 != 1) return false;
$d = 3;
$x = sqrt($i);
while ($i % $d != 0 && $d < $x) $d += 2;
return (($i % $d == 0 && $i != $d) * 1) == 0 ? true : false;
}
$total = 0;
$max = 1000000;
for($i=0;$i<$max;$i++)
{
if (is_prime($i))
{
echo “$i is a prime number”;
$total++;
}
}
echo “Total Number of Prime Numbers between 1 and $max is $total\n”;
?>
thanks hepled me with home work