Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ program please You will implement in this exercise an ancient Greek algorithm for finding the prime numbers less than a given number. Reminder: A

c++ program please

image text in transcribed

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 1 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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 1 1 18 19 20 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 3 4 5 6 7 8 9 10 11 12 13 14 1 1 0 0 1 16 17 15 18 19 20 Iteration 2: mark all the multiples of 3 as not prime Array: 00 1 1 0 1 0 1 0 0 0 1 0 1 0 Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 0 1 15 16 17 1 18 19 20 Iteration 4: mark all the multiples of 5 as not prime (4 is skipped) Array: 0 1 1 0 1 0 1 0 0 0 1 0 1 0 0 1 Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 0 18 19 20 Etc. Requirements. 1. Implement function void SetMultiples(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago