Everyone, crossing, start today. We talk about large couplet sci-tech fiction: C chestnuts, that is, C language examples.
Gossip Hugh,
Words return to the positive turn.
Let's talk C chestnuts together!
Crossing, they are. The last time we said is a sample of the conversion, this time we say the example is: Prime.
Primes are also called prime numbers, in natural numbers greater than 1. Suppose a positive integer except 1 and itself. cannot be divisible by other natural numbers. Then this
The number is a prime. The number of primes is much higher. So we'll just show the primes from 1 to 100 in this case.
Crossing that this example is simple. I think it's easier than that. Just walk through the numbers in the range and infer whether
Divisible by a number other than 1 and itself is possible. I specifically say prime number This example is to introduce the second method, this method can save
The time of traversal, improve the efficiency of program execution.
I used the principle in the example: if there is a positive integer n, except 1 and itself. With a square root from 2 to a positive integer n, all positive
Integer number to remove N. Suppose n is not divisible. Then the positive integer n is the prime number.
Using this method can reduce the number of traversal. thereby improving
The efficiency of the program.
Crossing, they are. No code is written in the text. The specific code in my resources, you can click the link to download the use.
Ladies and gentlemen, here's a sample of prime crossing. I want to know what the following example, and listen to tell.
Talk C Chestnut Bar (eighth time: C-language Instance-prime number)