sieveOfEratosthenes(N) returns a (N + 1)-dimensional vector whose ith component is 1 if i is a prime number, and 0 otherwise, where i = 0, 1, 2, ..., N. Hence, the two first components are both 0, and the third, corresponding to index i = 2, is the first 1.
sieveOfEratosthenes is very fast, and computing sieveOfEratosthenes(10000000) should take less than a half second on a modern computer.
Example: sieveOfEratosthenes(50) will return ❨0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0❩
Hint! Pass the returned vector to numberVector to get a numbered version of it!