The number of prime numbers between C languages printing 100-200

Source: Internet
Author: User

Prime number, also known as prime number, has an infinite number. A natural number greater than 1, except 1 and itself, cannot be divided by other natural numbers (prime numbers), in other words the number is no longer a factor other than 1 and itself; otherwise called composite.

According to the basic theorem of arithmetic, each integer greater than 1 is either a prime number or a product of a series of prime numbers, and the written form is unique if the order of the primes is not considered in the product. The smallest prime number is 2.

So far, people have not found a formula to find all prime numbers.

The C language code is as follows:

# include <stdio.h>int main ()                                 //Main function {   int i,j;                               //defines two cyclic variables    printf ("The prime number between 100-200 is:");    for (i=100; i<=200; i + +)               //outer for Loop     {       for (j=2; j<=i-1; j++)              //Inner Loop    {         if (i%j == 0)                //if can be 1 and it itself outsideThe number of integers is composite          {    break;  }       if (j == i-1)                //if not divisible, it is prime   {     printf ("%d\t", I);   //the cursor with a 8-character base for jumping output   }   }   }return 0;}


Dry Tip: The division of integers will perform "rounding", and any fractional portion of the result will be discarded.


This article is from the "Nobody" blog, please be sure to keep this source http://814193594.blog.51cto.com/10729329/1696717

The number of prime numbers between C languages printing 100-200

Related Article

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.