User Defined Functions: Finding Prime Numbers

edited November 2011 in Science & Tech
Basically this program is supposed to find the prime numbers between m and n, and it works! But I can't get it to do what I want it to do when I test negative numbers. Any idea where I went wrong here?



function [ pr ] = prime( m,n )
%Finds all the prime numbers between two numbers m and n.

v=m:n;
pr=v(isprime(v));

if m > n
pr = 'The value of n must be larger than the value of m.';
elseif m,n < 0
pr = 'The input argument must be a positive integer.';
elseif m < 0
pr = 'The input argument must be a positive integer.';


end

Comments

  • shwaipshwaip bluffin' with my muffin Icrontian
    edited November 2011
    open it in the debugger and see if you can figure it out. it should be pretty obvious when you step through using the debugger.
  • edited November 2011
    ok i'll keep working on it.
Sign In or Register to comment.