NAME

Math::Factor - factorise integers and calculate matching multiplications.

SYNOPSIS

use Math::Factor q/:all/;

@numbers = (9);

# data manipulation
%factors = factor (\@numbers);
%matches = match (\%factors);

# factors iteration
while ($factor = each_factor(\%factors, $numbers[0])) {
    print "$factor\n";
}

# matches iteration
while (@match = each_match(\%matches, $numbers[0])) {
    print "$numbers[0] == $match[0] * $match[1]\n";
}

DESCRIPTION

see above.

FUNCTIONS

factor

Factorises numbers.

%factors = factor (\@numbers);

Each number within @numbers will be entirely factorised and its factors will be saved within %factors, accessible by the number itself e.g the factors of 9 may be accessed by @{$factors{9}}.

match

Evaluates matching multiplications.

%matches = match (\%factors);

The factors of each number within %factors will be multplicated against each other and results that equal the number itself, will be saved to %matches. The matches are accessible through the according numbers e.g. the first two numbers that matched 9, may be accessed by $matches{9}[0][0] and $matches{9}[0][1], the second ones by $matches{9}[1][0] and $matches{9}[1][1], and so on.

each_factor

Returns each factor of a number in a scalar context.

while ($factor = each_factor(\%factors, $numbers[0])) {
    print "$factor\n";
}

each_match

Returns each match of a number in a array context.

while (@match = each_match(\%matches, $numbers[0])) {
    print "$numbers[0] == $match[0] * $match[1]\n";
}

EXPORT

factor(), match(), each_factor(), each_match() upon request.

TAGS

:all - *()

:factor - factor(), each_factor()

:match - match(), each_match()

SEE ALSO

perl(1)

LICENSE

This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Steven Schubiger