function isitprime = plg_isprime(n)

if (n<2)
    isitprime = false;
elseif (n==2)
    isitprime = true;
elseif (mod(n,2)==0)
    isitprime = false;
else
    isitprime = true;
    i1 = 3;
    i2 = floor(sqrt(n));                  % efficiency 1
    i = i1;
    while ((isitprime==true) & (i <= i2)) % efficiency 2
        if (mod(n,i)==0)
            isitprime = false;
        end;
        i = i + 2;                        % efficiency 3
    end;
end;

end