Why does eratosthenes sieve work
Note that some of these, such as 6, will already be marked out. The next integer on the list that is not marked out is 5, and it is prime. Mark out all multiples of 5 that are bigger than 5 because they are composite. Continue in this way until there is no next integer on the list that is not marked out. In the video in Figure In Figure All composites marked out in Figure Explore the sieving process in Figure Click on a number to have all its multiples marked by changing the field color to red and crossing them out.
Numbers that you have clicked appear on green background. When there are no white fields left, the numbers in green fields are all the prime numbers up to Learn more. Ask Question.
Asked 3 years, 8 months ago. Active 7 months ago. Viewed 2k times. Is there an explanation? Martin Sleziak Z1pp3d Z1pp3d 53 7 7 bronze badges. It was just memory. Add a comment.
Active Oldest Votes. Pushparaj Pushparaj 3 3 bronze badges. We create a list of all numbers from 2 to According to the algorithm we will mark all the numbers which are divisible by 2 and are greater than or equal to the square of it. Now we move to our next unmarked number 3 and mark all the numbers which are multiples of 3 and are greater than or equal to the square of it.
Skip to content. Change Language. Related Articles. Table of Contents. Save Article. Improve Article. Like Article. Attention reader!
SieveOfEratosthenes n ;.
0コメント