information:classification
Pseudocode

The sieve of Eratosthenes can be expressed in pseudocode, as follows:

This algorithm produces all primes not greater than n. It includes a common optimization, which is to start enumerating the multiples of each prime i from i. The time complexity of this algorithm is O (n log log n), provided the array update is an O (1) operation, as is usually the case.