The first step in the algorithm is to list all the natural numbers from two up to and including the number being tested (n). Next, starting at the beginning of the list, find the first number that is not crossed out, and cross out all of its multiples. After this, proceed to the next number that is not crossed out and cross out its multiples. Repeat this process until you reach the square root of the number you are examining. Any number that is not crossed out at the end is prime. The algorithm is best explained with an example

credits :http://banach.millersville.edu/~bob/math478/History/sieve.html

## No comments:

## Post a Comment