Question: C++ Ex 3. Prime Numbers (30 points) You will implement in this exercise an ancient Greek algorithm for finding the prime numbers less than a
C++

Ex 3. Prime Numbers (30 points) You will implement in this exercise an ancient Greek algorithm for finding the prime numbers less than a given number. Reminder: A prime number is a positive integer greater than I that is divisible only by itself and by 1. Here is how the algorithm works assuming we would like to find the prime numbers 1 are assumed to be prime 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Iteration 1: mark all the multiples of 2 as not prime Array: 0 0 1 1 0 1 0 1 0 1 0 1 0 1 Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Iteration 2: mark all the multiples of 3 as not prime Array: 0 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 i Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Iteration 4: mark all the multiples of 5 as not prime (4 is skipped) Array: 0 1 1 0 1 0 1 0 0 1 0 1 0 0 1 0 1 Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 20 18 19 1 16 1 17 18 1 19 9 20 19 20 0 19 20 Etc. Requirements. 1. Implement function void flip_multiples(int a[], int size, int num) which marks all the multiples of num in the array as not prime (excluding num). 2. Write a program that prints the prime numbers
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
