Answered step by step
Verified Expert Solution
Question
1 Approved Answer
how do you do this on matlab ? 4 Prime Evaluation Input * Output result function result - primeCheck (x) Type Description 1x1 double A
how do you do this on matlab ?
4 Prime Evaluation Input * Output result function result - primeCheck (x) Type Description 1x1 double A positive integer Type Description IxNchar character array that is either 'Non-Prime' or 'Prime 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 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. Page 5 of 8 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
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