CoreChallenge 12 of 34

Sieve of Eratosthenes

Write primes_up_to(limit) that returns a of all prime numbers ≤ limit, using the sieve: mark multiples of each prime as composite rather than testing each number individually.

Examples
primes_up_to(20) → [2, 3, 5, 7, 11, 13, 17, 19]
Exercise

Sieve of Eratosthenes

3 checks
def primes_up_to(limit):
    ...


print(primes_up_to(20))
 
Python (loads on first run)Ctrl+Enter runs
Output
Press Run to try your code, then Check answer to grade it.