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++
c++ Ex 3. Prime Numbers (30 points) You will implement in this

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 divisiblc 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 em 111111111 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 18 19 20 Iteration 1: mark all the multiples of 2 as not prime Array: a 0 1 1 0 1 0 1 0 1 0 1 1 1 Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Iteration 2: mark all the multiples of 3 as not prime Array: @ @ 1 1 0 1 0 1 0 1 1 @ @ @ 1 Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Iteration 4: mark all the multiples of 5 as not prime (4 is skipped) Array: 911 eiieee 1 1 1 Index: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 1 e 19 20 1 e 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!