\(P_n\text{,}\) the vector space of polynomials with degree at most \(n\text{,}\) has dimension \(n+1\) by 2.1. [Cross-reference is just a demo, content is not relevant.] What happens if we relax the defintion and remove the parameter \(n\text{?}\)
The Sieve of Eratosthenes computes prime numbers by starting with a finite list of the integers bigger than 1. The first member of the list is a prime and is saved/recorded. Then all multiples of that prime (which not a prime, excepting the prime itself!) are removed from the list. Now the first number remaining in the list is the next prime number. And the process repeats.
The code blocks below can be rearranged to form one of the many possible programs to implement this algorithm to compute a list of all the primes less than \(250\text{.}\) [Ed. this version of this problem requires the reader to provide the necessary indentation.]
n = 250
---
primes = []
candidates = list(range(2,n))
---
candidates = []
primes = list(range(2,n)) #paired
---
primes = candidates + [p] #distractor
---
while candidates:
---
p = candidates[0]
primes.append(p)
---
for nonprime in range(p, n, p):
---
if nonprime in candidates:
candidates.remove(nonprime)
---
print(primes)