gogoWebsite

python prime number (filter method) (simple prime number filtering method)

Updated to 20 hours ago

Prime numbers are prime numbers, and the following are expressed as prime numbers
The screening method is also called screening method. The specific method is: first arrange N natural numbers in order.

1 is not a prime number, nor is it a composite number.Skip。(Combination numberRefers to a number in a natural number that can be divided by 1 and itself, except for 1 and itself. Contrary to prime number)

The second number 2 is the prime number left, andSkip all the numbers that can be divisible by 2 after 2

The first number that has not been cut after 2 is 3. Leave 3 and thenSkip all the numbers that can be divisible by 3 after 3

The first number that has not been cut after 3 is 5. Leave 5 and thenSkip all the numbers that can be divisible by 5 after 5

Keep doing thisAll the combined numbers not exceeding N will be screened out, and all the prime numbers not exceeding N will be left behind.

Because the Greeks wrote numbers on a waxed board, and every time a number was cut, they recorded small dots on it. After the work of seeking prime numbers was completed, these small dots were like a sieve, so the method of Elatostney was called "Elatostney sieve", abbreviated as "sieve method".

(Another explanation is that the number at that time was written on papyrus. Whenever a number was cut, the number was dug out. After the work of seeking prime numbers was completed, these small holes were like a sieve.)