NAME
Math::Counting - Counting operations for probability and combinatorics
SYNOPSIS
use integer; # optional
use Memoize; # optional
use Math::Counting;
my $n = 123;
my $r = 42;
my $x = Math::Counting->new( $n, $r );
printf "Given n=%d and r=%d:\nFact=%d\nPerm=%d\nComb = %d\n",
$n, $r, $x->factorial, $x->permutation, $x->combination;
DESCRIPTION
Compute the numerical factorial, number of permutations or combinations.
PUBLIC METHODS
new
$x = Math::Counting->new( $n, $r );
Return a new Math::Counting
object.
factorial
$f = $x->factorial(); # Uses the settings from construction
$f = $x->factorial( $n );
Return the factorial of n (n!).
permutation
$p = $x->permutation(); # Uses the settings from construction
$p = $x->permutation( $n, $r );
Return the number of permutations of n items given r.
combination
$c = $x->combination(); # Uses the settings from construction
$c = $x->combination( $n, $r );
Return the number of combinations of n items given r.
TO DO
Export small functions instead of object methods as an option.
THANK YOU
Mark Jason Dominus for writing Memoize
and Higher Order Perl
and for mentioning this URL to me:
SEE ALSO
http://www.plover.com/~mjd/misc/perl/pc.pl
COPYRIGHT
Copyright 2005, Gene Boggs, All Rights Reserved
LICENSE
You may use this module under the terms of the BSD, Artistic, or GPL licenses, any version.
AUTHOR
Gene Boggs <gene@cpan.org>