Skip to content

Instantly share code, notes, and snippets.

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