← All challenges
✓ Solved
Sieve of Eratosthenes
Find every prime number up to 50 -- efficiently, not by checking each one individually.
🔴 ExtremeDifficulty
The challenge
Print every prime number from 2 to 50, space-separated on a single line, using the Sieve of Eratosthenes algorithm (mark multiples of each prime as not-prime, rather than testing each number for primality individually).
🧠 Need a hint? (Python)
Make a boolean list is_prime of size n+1, all True except index 0 and 1. For each i from 2 up to sqrt(n), if is_prime[i], mark every multiple of i (starting at i*i) as False.
🚀
Like solving these?
Structured courses, hands-on exercises, and real multi-file projects are waiting -- your first project unlock is free.
Create a free account