% integer_prime.m
%
%  Report whether the integer J is a prime.
%
j = input ( '  Enter integer J to check: ' );

itsaprime = true;

for i = 2 : j - 1
  if ( mod ( j, i ) == 0 )
    itsaprime = false;
    fprintf ( '  %d is divisible by %d\n', j, i );  
  end
end

if ( itsaprime )
  fprintf ( '  %d is prime.\n', j );
else
  fprintf ( '  %d is not a prime\n', j );
end
