Question: (a) Write a function isPrime (n) that takes an integer n and returns true if the number is prime or false if it is

(a) Write a function isPrime(n) that takes an integer n and returns true if the number is prime or false if 

(a) Write a function isPrime (n) that takes an integer n and returns true if the number is prime or false if it is not. Your function must not use the isPrime built in function, but you can use whatever other MATLAB functions you want. A number, n, is not prime if any number between 2 and n/2 divides the number without any remainder. (b) For the isPrime function above, give three test cases that will test a range of outcomes. For each test case explain what types of inputs that case is testing and give the expected output.

Step by Step Solution

3.48 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The image shows a question that is divided into two parts a and b which are related to writing and testing a prime number checking function in MATLAB ... View full answer

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 Algorithms Questions!