Question: in matlab please help with this function 4 Prime Evaluation Input function result = primeCheck (x) Type Description 1x1 double A positive integer Type Description
4 Prime Evaluation Input function result = primeCheck (x) Type Description 1x1 double A positive integer Type Description 1xN char A character array that is either 'Non-Prime' or 'Prime Output result Details You are required to write a recursive program that is able to evaluate if a positive integer x is a prime number. A prime number is defined as a positive integer that is not divisible without remainder by any integer except itself and 1. You are NOT ALLOWED to use the built-in MATLAB function isprime(). Your program should do the following: 1. Verify that x is a positive integer. 2. Evaluate if the integer x is a prime. 3. Display a message to the user if they used an invalid input using the MATLAB function disp. Tips Remember that 1 is not a prime number, and the only even prime number is 2. Because your function has only one input and you are restricted to writing a recursive program, the use of a persistent variable may be helpful to act as a potential divisor of x. If you use a persistent variable, clear it when your program concludes. This will help avoid computational mistakes the next time your function is called
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
