function s = permn(m,n)
% This function count number of arrangements posibles with m distincts
% elements grouped in groups of size n elements, without repetition, and order being
% important
% $  nPr = P(n,r) = n! / (n-r)!$
switch nargin
    case 1
        s =factorial(m);
    case 2
    if m<n    error('n must be an integer between 0 and m.')
    else
        s = prod(m:-1:m-n);
    end
    otherwise
        error('Too many input arguments.')
 end
