Question: Implement the sieve of Eratosthenes: a method for computing prime numbers, known to the ancient Greeks. This method computes all prime numbers up to n.
Implement the sieve of Eratosthenes: a method for computing prime numbers, known to the ancient Greeks. This method computes all prime numbers up to n. Choose an n. First insert all numbers from 2 to n into a set. Then erase all multiples of 2 (except 2); that is, 4, 6, 8, 10, 12, . . . . Erase all multiples of 3; that is, 6, 9, 12, 15, . . . . Go up to n. Then print the set.
Step by Step Solution
3.33 Rating (159 Votes )
There are 3 Steps involved in it
n 20 Set 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Remove all m... View full answer
Get step-by-step solutions from verified subject matter experts
