search.cpan.org is shutting down
Steven Schubiger (stsc) > Math-Factor-XS-0.38 > Math::Factor::XS

Math-Factor-XS-0.38.tar.gz

Dependencies

Annotate this POD

# CPAN RT

 New 1 Open 1
View/Report Bugs
Module Version: 0.38   Source   Latest Release: Math-Factor-XS-0.40

# NAME

Math::Factor::XS - Factorize numbers and calculate matching multiplications

# SYNOPSIS

``` use Math::Factor::XS ':all';
# or
use Math::Factor::XS qw(factors matches);

\$number = 30107;

@factors = factors(\$number);
@matches = matches(\$number, \@factors);

print "\$factors[1]\n";
print "\$number == \$matches[0][0] * \$matches[0][1]\n";```

# DESCRIPTION

`Math::Factor::XS` factorizes numbers by applying trial divisions.

# FUNCTIONS

## factors

Factorizes numbers.

` @factors = factors(\$number);`

The number will be entirely factorized and its factors will be returned as a list.

## matches

Calculates matching multiplications.

` @matches = matches(\$number, \@factors, { skip_multiples => [0|1] });`

The factors will be multiplicated against each other and all combinations that equal the number itself will be returned as a two-dimensional list. 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 pair by `\$matches[1][0]` and `\$matches[1][1]`, and so on.

The hashref provided at the end is optional. If `skip_multiples` is set to a true value, then matching multiplications that contain multiplicated small factors will be discarded. Example:

``` 11 * 2737 == 30107 # accepted
77 * 391  == 30107 # discarded```

Direct use of `\$Math::Factor::XS::Skip_multiple` does no longer have an effect as it has been superseded by `skip_multiples`.

# EXPORT

## Functions

`factors(), matches()` are exportable.

## Tags

`:all - *()`

# AUTHOR

Steven Schubiger <schubiger@cpan.org>