This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sieve(n): | |
''' | |
find all primes less than n | |
parameter: a natural number n | |
return: array of length n | |
the ith element is a binary flag that indicates if the natural number i is prime | |
(1 for prime, 0 for composite) | |
''' | |
x = [1] * n | |
x[1] = 0 |