| Input: an integer n > 1 | | | | Let A be an array of Boolean values, indexed by integers 2 to n, | | initially all set to true. | | | | for i = 2, 3, 4, ..., while i ≤ n/2: | | if A[i] is true: | | for j = 2i, 3i, 4i, ..., while j ≤ n: | | A[j] = false | | | | Now all i such that A[i] is true are prime.COPY |
|