Answered step by step
Verified Expert Solution
Link Copied!

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 ?
image text in transcribed
image text in transcribed
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

5. List the forces that shape a groups decisions

Answered: 1 week ago

Question

4. Identify how culture affects appropriate leadership behavior

Answered: 1 week ago