function [isPrime,divisor] = testPrime(n)
%This is a function that takes as input an integer n >= 2
%and determines whether n is prime. 
%returns the variables 'maybePrime' and 'divisor' as output
%
%A Matlab function, if it occupies its own file, 
%should have the same name as the M-file 
%(in this case, 'testPrime'). 
%
%We can then call this function from other programs, 
%or from the command line


isPrime = true; % after the code runs, the function returns
                   % the current value of maybePrime
divisor = NaN;     % If we find a divisor, return the smallest one. 

					   				  
for i = 2:sqrt(n)
    if mod(n,i) == 0
        isPrime = false; 
        divisor = i; 
        return % return instantly ends the routine and
			   % returns the value of maybePrime
    end
end


end