Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
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 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
C PROGRAM
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started