Question: In MATLAB please!! Write a function ( not a script ) that does the following: ( a ) The input to the function is a
In MATLAB please!!
Write a function not a script that does the following:
a The input to the function is a positive integer n
b The function will determine if the the number is a prime number or not.
c The function returns if the number is prime and if the number is not prime.
d The function should be called isPrimeNum and exist in a file called isPrimeNum.m MatlabOc
tave are case sensitive
e MatlabOcatve have a builtin function called isprime n that does this already. You can't call
that function in your function because that's cheating. You may use the builtin gcd function
though. Your function should start out this way.
function y isPrimeNumn
This function will compute if a positive integer n is prime.
if n
dispOops n should be a positive integer';
y;
return
end
if n ~ floorn
dispOops n should be a positive integer';
y;
return
end
Your actual code should start below here.
Show results for running the following code
isPrimeNum
isPrimeNum
isPrimeNum
isPrimeNum
isPrimeNum
isPrimeNum
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
