function O=perm(N,k)
% format O=perm(N,k)
% Number of permutations of N objects, k at a time.
% Based on Theorem 2.9.1 in 
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Writtten by Eugene Gallagher, Eugene.Gallagher@umb.edu
% http://alpha.es.umb.edu/faculty/edg/files/edgwebp.html
% Written 1/15/2011 & last revised 1/16/2011
if N<40;
    O=factorial(N)/factorial(N-k);
else
    O=exp(gammaln(N+1)-gammaln(1+N-k))
end
