Question: Using MatLab Write a function called PrimeFinder that receives an integer n as an input argument, and provides an output argument called Primes that is

Using MatLab Write a function called PrimeFinder that receives an integer n as an input argument, and provides an output argument called Primes that is a vector containing all prime numbers between 2 and n, inclusive. Verify the correctness of your code with inserting 13 as the input argument, and check that your output is Primes = [2,3,5,7,11,13]. You are NOT allowed to use any directly relevant MATLAB built-in function such as divisors, etc.

NOTE: A prime number is a number that is only divisible by 1 and itself.

HINT: Your function should go through all integers between 2 and n, one by one, and check if that number is divisible by any number other than 1 or itself. If the number turned out to be a prime number, it should be appended to the end of the output argument vector before moving on to the next number.

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!