Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: print prime
Date: Thu, 24 Sep 2009 12:23:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 28
Message-ID: <h9fob7$hs7$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1253794983 18311 172.30.248.35 (24 Sep 2009 12:23:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 24 Sep 2009 12:23:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1984697
Xref: news.mathworks.com comp.soft-sys.matlab:572594


I wrote a program, but this is so buggy I guess?
I have this P4 2.6Ghz pc & 1GB Ram, I guess it's running out of memory or something. 

Some numbers it will print not a prime / is a prime.

Let say primeTest(1)
it will say it's a prime

but when you do like primeTest(10)
nothing shows instead, on the bottom of the matlab (where the start menu is located), it will say "busy". 

is there something i misunderstood my own program?


function primeTest(x)
n = 3;
R=rem(x,n);
while R ~= 0 & n < sqrt(x) & n < 10
    n+2;
    r=rem(x,n);
end
if R ~= 0
    disp('Is a prime')
else
    disp('Not a prime')

end
end