Question: create a function in Scheme that finds the prime numbers in a list using the ancient method called Sieve of Eratosthenes. It will take one

create a function in Scheme that finds the prime numbers in a list using the ancient method called Sieve of Eratosthenes. It will take one parameter that determines the max number. You will begin with a list from (2 - maxNum) that will remove all numbers in a list divisible by 2, and then all the numbers in the list divisible by 3. This continues until the square root of maxNum is reached.

Example (prime-finder 10)

'(2 3 5 7)

To do this, please implement the functions you have already completed including:

*is-not-divisible-by - which takes 2 parameters and returns false if a number is divisible by the given number. For example if the given number is 10 and 2 will return false. This will go into the helper function.

*filter-function - which takes a function and a list as a parameter and uses the function to create a list of true values. For example if a function is passed through called "less-than-5" only values less than 5 will be featured in the list. This will go into the helper function.

*create-list-from -which takes one parameter creates a list from 2 to the given number. This will go in the main function

The above functions are already completed. I need help with implementing them into the helper function and prime function.

Please do not use cons, display, or map.

This is in Scheme. Please do not respond in the wrong language or to say the language is not listed.

Thank you!

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!