Math::Factor - Factorise numbers and calculate matching multiplications
use Math::Factor ':all'; $number = 30107; @factors = factors($number); @matches = matches($number, @factors); print "$factors\n"; print "$number == $matches * $matches\n";
Math::Factor factorises numbers by applying trial divison.
@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 and $matches, the second ones by $matches and $matches, and so on.
If $Math::Factor::Skip_multiple is set to a true value, matching multiplications that contain multiplicated (small) factors will be dropped.
# accepted 30107 == 11 * 2737 # dropped 30107 == 77 * 391
factors(), matches() are exportable.
:all - *()