Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

help matlab Finding Primes In a (unction file named findPrimes.m, write a user-d

ID: 3697207 • Letter: H

Question


help matlab

Finding Primes In a (unction file named findPrimes.m, write a user-defined function named findPrimes that finds all the pfime numbers between two numbers m and n. Name the function pr = findPrimes(m, n), where the input arguments mand n arc positive integers and the output argument pr is a vector with the prime numbers. If m > n is entered when the function is called, the error message "The value of n must be larger than the value of m." is displayed. If a negative number of a number that is not an integer is entered when the function Is called, the error

Explanation / Answer

function [Prime] = PrimeNum3(N,M)

if (N>M || N <0 || M < 0)

    error('ERROR: Invalid Input, you entered biggere number first or you entered negative number as you interval.');

end

Prime = [];

for j=0:(M-N)

    if all(mod((N+j),2:((N+j)/2))),

Prime = [Prime;N+j];

end

end

note- the above function can help to answer the given question.