Copy code The code is as follows:
for($i = 2; $i < 1001; $i++) {
$primes = 0;
for($k = 1; $k <= $i; $k++)
if($i%$k === 0) $primes++;
if($primes <= 2) // An integer that can be divided by 1 and itself (excluding 0)
echo "{$i}< br />";
}
http://www.bkjia.com/PHPjc/825246.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825246.htmlTechArticleCopy the code as follows: ?php for($i = 2; $i 1001; $i++) { $primes = 0; for($k = 1; $k = $i; $k++) if($i%$k === 0) $primes++; if($primes = 2)// Can be divided by 1 and itself Integer (excluding...