"python "Sieve of Eratosthenes The sieve of Eratosthenes is a way of computing all the prime numbers below a certain number. (A prime number is a number that is only divisible by itself and 1). This algorithm is explained excellently in this video (Links to an external site.), or you can read about this ancient algorithm on Wikipedia (Links to an external site.). Implement this algorithm: Implement a function cross_out_multiples that takes as arguments a list of boolean values (true/false) called is_prime and a number n. The function sets the boolean values at all multiples of n (2*n, 3*n, 4*n ...) that are in the list to false. Implement a function sieve(n) which gives back a list of all primes below n. """
"python
"Sieve of Eratosthenes
The sieve of Eratosthenes is a way of computing all the prime numbers below a certain number.
(A prime number is a number that is only divisible by itself and 1).
This
or you can read about this ancient algorithm on Wikipedia (Links to an external site.).
Implement this algorithm:
Implement a function cross_out_multiples that takes as arguments a list of boolean values
(true/false) called is_prime and a number n. The function sets the boolean values at all multiples of n (2*n, 3*n, 4*n ...)
that are in the list to false.
Implement a function sieve(n) which gives back a list of all primes below n. """
def cross_out_multiples(is_prime,n) :
is_ptime=True
n=False
pass
def sieve(n):
pass
Trending now
This is a popular solution!
Step by step
Solved in 2 steps