Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function crossOffMultiples ( ) that takes a list of booleans and an integer from 2 to 1 0 0 as the starting value.
Write a function crossOffMultiples that takes a list of booleans and an integer from to as the starting value. Your function will eliminate all the multiples by setting the value at the index of a multiple to false. Your list will start with all true values.
crossOffMutiples will return the list.
Example: multiplesList of size
tablemultiplesListtrue,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True
Result of function call: crossoffMultipes multiplesList
tablemultiplesListtrue,True,True,True,False,True,False,True,False,True,False,True,False,True,False,True,False,True,False,True,False
Create the multiplesList in the shell or in your py fileWrite a function sieve that finds all the prime numbers from to You will use an ancient algorithm called the Sieve of Eratosthenes. Essentially the Sieve works by crossing off all the multiples of a number, starting with the integer Once you cross off all the multiple values of you then proceed to the next available integer, not crossed off and cross off its multiples. After sieve has finished crossing off all possible multiples, your function will print the prime numbers. HINT: use your function crossOffMultiples to reduce the complexity of your algorithm. Abstraction is your friend!ne numbers
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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