NAME
Math::Counting - Efficient combinatorial counting operations
SYNOPSIS
use Math::Counting qw( factorial permutation combination );
my $n = 42;
my $r = 27;
printf "Given n=%d and r=%d:\nFact=%d\nPerm=%d\nComb=%d\n",
$n, $r, factorial($n), permutation($n, $r), combination($n, $r);
DESCRIPTION
Compute the numerical factorial, number of permutations and number of combinations using the efficient technique of "tail call elimination" as detailed in Higher Order Perl and based on the algorithms in Mastering Algorithms with Perl.
FUNCTIONS
factorial
$f = factorial($n);
Return the number of arrangements of n.
permutation
$p = permutation($n, $k);
Return the number of arrangements of n elements drawn from a set of n elements.
combination
$c = combination($n, $r);
Return the number of ways to choose r elements from a set of n elements.
TO DO
Provide the gamma function for the factorial of non-integer numbers.
COPYRIGHT AND LICENSE
Copyright 2005, Gene Boggs, All Rights Reserved
You may use this package under the same terms as Perl itself.
AUTHOR
Not me. I am but a pebble on the beach.
SEE ALSO
Higher Order Perl by Mark Jason Dominus (http://hop.perl.plover.com/).
Mastering Algorithms with Perl by Orwant, Hietaniemi & Macdonald (http://www.oreilly.com/catalog/maperl/).