Crossing, everyone, from today onwards, we talk about the large-scale couplet science fiction: C Chestnut, that is, C language examples. Gossip Hugh,
Words return to the positive turn. Let's talk C chestnuts together!
Crossing, the last time we were talking about the example of a conversion, this time we say the example is: Prime.
Prime is also called Prime, in the natural number greater than 1, if a positive integer other than 1 and itself, can not be divisible by other natural numbers, then this
The number is a prime. The prime numbers are more, so we only show the primes from 1 to 100 in this case.
Crossing that this example is simple, I think it is relatively simple. Just walk through the number in the range to determine if it can be
Divisible by a number other than 1 and itself. I specifically say prime numbers This example is to introduce another method, this method can save
Traverse the time, improve the program running efficiency.
I use the principle in the example: if there is a positive integer n, except 1 and itself, with the square root from 2 to positive integer n, all the positive
Integer number to remove N, if n is not divisible. Then the positive integer n is the prime number. Using this method can reduce the number of traversal and thus improve
The efficiency of the program.
Crossing, the text does not write code, the detailed code put in my resources, you can click the link to download the use.
You crossing, we're going to talk about prime numbers here. I want to know what the following example, and listen to tell.
Talk C Chestnut Bar (eighth time: C-language Instance-prime number)