Question: algorithm Sieve of Eratosthenes is input: an integer nn > 1 . output: all prime numbers from 2 through n . let A be an

algorithm Sieve of Eratosthenes is
input: an integer nn >1.
output: all prime numbers from 2 through n.
let A be an array of Boolean values, indexed by integers 2 to nn,
initially all set to true.
for i =2,3,4,..., not exceeding nn do
if A[i] is true
for j = i2, i2+i, i2+2i, i2+3i,..., not exceeding n do
set A[j] := false
return all i such that A[i] is true.

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!