Question: C PROGRAM 6.7. Prime numbers can also be generated by an algorithm known as the Sieve of Erastosthenes The algorithm for this procedure is presented

 C PROGRAM 6.7. Prime numbers can also be generated by an C PROGRAM

6.7. Prime numbers can also be generated by an algorithm known as the Sieve of Erastosthenes The algorithm for this procedure is presented here. Write a program that implements this algorithm. Have the program find all prime numbers up to n = 150, what can you say about this algorithm as compared to the ones used in the text for calculating prime numbers? Sieve of Erastosthenes Algorithm To Display All Prime Numbers Between 1 and n Step 1: Define an array of integers P. Set all elements P, to 0,2 n, the algorithm terminates. Step 4: If P, is 0,then i is prime Step 5: For all positive integer values of j, such that i x jn, set Pay to Step 6: Add 1 to i and go to step 3

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!