Home > Backend Development > PHP Tutorial > Example of php outputting prime numbers (prime numbers) within 1000_PHP tutorial

Example of php outputting prime numbers (prime numbers) within 1000_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:24:59
Original
1449 people have browsed it

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 />";
}

www.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...
Related labels:
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template