Php output Prime number within 1000 (prime number) example _ PHP Tutorial

Source: Internet
Author: User
Php outputs an example of prime number (prime number) within 1000. Copy the code as follows :? Phpfor ($ i2; $ i1001; $ I ++) {$ primes0; for ($ k1; $ k $ I; $ k ++) if ($ I % $ k0) $ primes ++; if ($ primes2) can be divided by 1 and its own integers (excluding The code is as follows:


For ($ I = 2; I 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 its own integer (excluding 0)
Echo"{$ I}
";
}

The http://www.bkjia.com/PHPjc/825246.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/825246.htmlTechArticle code is 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) // The integer that can be divided by 1 and itself (excluding...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.