function output = aPrime(m)
% output is 1 if m is a prime number, 0 otherwise.  m>1.

d= 2;  % divisor to test
while (mod(m,d)~=0)
    d= d+1;
end
if (d==m)  % 1st divisor found is m itself
    output= 1;
else
    output= 0;
end

%Note:  the last if-else can be replaced by the single statement
%       output= d==m
