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...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn