For loop find prime number 2 to 100 (prime number)

Source: Internet
Author: User

#提供一个大循环数字序列给num
For NUM in range (2,100):
#循环条件是: Iterates through a sequence of numbers from 2 to NUM, each time the number sequence of loops is assigned to I.
For I in Range (2,num):
#如果num余运算i为0, break the small loop over to the big loop.
If num%i = = 0:
Break
The number (prime) is printed #小循环余运算到了num的尽头for不再成立 (the loop is not interrupted).
Else
Print (num)
#我可能一开始就啃了for循环里比较难啃的一块骨头, barely understood.

For loop find prime number 2 to 100 (prime number)

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.