Math::Factor - Factorise numbers and calculate matching multiplications
use Math::Factor ':all'; $number = 30107; @factors = factors($number); @matches = matches($number, @factors); print "$factors[1]\n"; print "$number == $matches[0][0] * $matches[0][1]\n";
Math::Factor factorises numbers by applying trial divison.
Factorises numbers.
@factors = factors($number);
$number will be entirely factorised and its factors will be saved within the array @factors.
Evaluates matching multiplications.
@matches = matches($number, @factors);
The factors within @factors will be multplicated against each other and results that equal the number itself, will be saved to the two-multidimensional array @matches. The matches are accessible through the indexes, for example, the first two numbers that matched the number, may be accessed by $matches[0][0] and $matches[0][1], the second ones by $matches[1][0] and $matches[1][1], and so on.
If $Math::Factor::Skip_multiple is set to a true value, matching multiplications that contain multiplicated (small) factors will be dropped.
Example:
# accepted 30107 == 11 * 2737 # dropped 30107 == 77 * 391
factors(), matches() are exportable.
factors(), matches()
TAGS
:all - *()
To install Math::Factor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::Factor
CPAN shell
perl -MCPAN -e shell install Math::Factor
For more information on module installation, please visit the detailed CPAN module installation guide.