function value = is_prime3 ( n )

%*****************************************************************************80
%
%% is_prime3() reports whether an integer is prime.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 December 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer n: the value to be tested.
%
%  Output:
%
%    logical value: true if n is a prime.
%
  if ( n <= 1 )
    value = false;
    return;
  end

  if ( ( n == 2 ) || ( n == 3 ) )
    value = true;
    return;
  end

  if ( ( mod ( n, 2 ) == 0 ) || ( mod ( n, 3 ) == 0 ) )
    value = false;
    return;
  end

  for i = 5 : 6 : sqrt ( n )
    if ( ( mod ( n, i ) == 0 ) || ( mod ( n, i + 2 ) == 0 ) )
      value = false;
      return;
    end
  end

  value = true;
  return;
end
