primes_up_to(n) that returns a sorted list of all prime numbers less than or equal to n, computed using the Sieve of Eratosthenes implemented with nested loops (a boolean list marking composites).primes_up_to(20)
[2, 3, 5, 7, 11, 13, 17, 19]
All primes up to 20.
primes_up_to(1)
[]
No primes exist at or below 1.
Create a boolean list `is_prime` of size n+1, initialized True, with index 0 and 1 set False.
For each prime p found, mark all its multiples starting at p*p (or 2*p) as not prime using an inner loop.