Use phyton TheSieve of Eratosthonesis an algorithm to find all the prime numbers between 1 andsome integerN. It can be implemented with nestedforloops:(a) Make a list of all the integers from 2 throughN.(b) Cross off all the multiples of 2 (except for 2 itself). The smallest number that remains(after 2) is 3.(c) Cross off all the multiples of 3 (except for 3 itself). The smallest number that remainsis 5.(d) Cross off all the multiples of 5 (except for 5 itself). The smallest number that remainsis 7.(e)···(f) Repeat looking for the smallest numberpthat remains and crossing off all of its multiples(except forpitself) until you reach√N.(g) All of the numbers that remain are primeUse the Sieve to print all the prime numbers under 1000.
Are there any questions left?
New questions in the section Engineering
-
Engineering 2022-05-15 19:04:59