Code covered by the BSD License  

Highlights from
ispair

from ispair by Kling & Freitag GmbH
find if a natural number is pair or not...

ispair(varargin)
function y = ispair(varargin)
%ISPAIR True for pair Integer numbers.
%
%   ISPAIR(a) for the integer value a returns 1 if a is a PAIR number 
%   and 0 if a is IMPAIR
%
%   See also ISPRIME, ISFINITE, ISINF, ISNAN.

%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DATE     : 02-03-2006
% FIRMA    : Kling & Freitag GmbH - Hannover
% AUTHOR   : Jos Ramn Menzinger ( j.r.menzinger@kling-freitag.de )
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if nargin < 1
    error('MATLAB:ISPAIR:NotEnoughInputs', 'Not enough input arguments.');
elseif nargin > 2 || numel(varargin{1}) > 1
    x = int16(varargin{1}(1));
    warning('MATLAB:ISPAIR:TooManyInputs', ['Too many input arguments, it will be considered only the first one: ' num2str(varargin{1}(1))]);
else
    x = int16(varargin{1});
end



if ~isinteger(x)
    error('Fucntion ispair is defined only for ONE INTEGER number')
end

if  mod(x,2) == 0
    y = true;
else % case "mod(x,2) == 1 " !!!!
    y = false;
end

Contact us at files@mathworks.com