Question: void sieve(int array[], int size) Write a function that will find all of the prime numbers between 0 and some number. (By definition, 0 and
void sieve(int array[], int size)
Write a function that will find all of the prime numbers between 0 and some number. (By definition, 0 and 1 are not prime, so you are really searching in the range of 2 to some number. We'll see why we consider 0 and 1 later.) The function will use an array to indicate the prime numbers in the range. For example, this is the list of all prime numbers between 2 and 100:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
The method that you will use to find all of the primes in a range is called the Sieve of Eratosthenes. The idea is that you start with a list of all numbers in the range that you want to find prime numbers. So, if we want to find all of the primes between 2 and 100, we'd start with the list:
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, . . ., 96, 97, 98, 99, 100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
