search.cpan.org is shutting down
Kevin Ryde > Math-NumSeq-72 > Math::NumSeq::AllPrimeFactors

Math-NumSeq-72.tar.gz

Dependencies

Annotate this POD

Website

# CPAN RT

 Open 0
View/Report Bugs
Module Version: 72

# NAME

Math::NumSeq::AllPrimeFactors -- prime factors of the integers

# SYNOPSIS

``` use Math::NumSeq::AllPrimeFactors;
my \$seq = Math::NumSeq::AllPrimeFactors->new;
my (\$i, \$value) = \$seq->next;```

# DESCRIPTION

This is a list of the prime factors of the integers 2, 3, 4, etc

```    starting i=1
2, 3, 2, 2, 5, 2, 3, 7, 2, 2, 2, 3, 3, 2, 5, 11, ...

\--/     \--/     \-----/  \--/  \--/
4    5   6    7    8       9     10   11```

## Order

The optional `order` parameter (a string) can control the order of the primes within each integer,

```    "ascending"     the default
"descending"```

For example "descending" rearranges the values to

```    # order => "descending"
2, 3, 2, 2, 5, 3, 2, 7, 2, 2, 2, 3, 3, 5, 2, 11, ...

\--/     \--/     \-----/  \--/  \--/
4    5   6    7   8        9     10   11```

The first difference is 3,2 for 6 (instead of 2,3).

## Multiplicity

Option `multiplicity => "distinct"` can give just one copy of each prime factor.

```    # multiplicity => "distinct"
2, 3, 2, 5, 2, 3, 7, 2, 3, 2, 5, 11, ...

\--/           \--/
4  5   6    7  8  9   10   11```

## On Values

Option `on_values` can give the prime factors of just some integers,

```    "all"           the default
"composites"    the non-primes from 4 onwards
"odd"           odd integers 3 onwards
"even"          even integers 2 onwards```

"odd" is not simply a matter of filtering out 2s from the sequence, since it takes the other primes from the even integers too, such as the 3 from 6.

```    # on_values => "odd"
3, 5, 7, 3, 3, 11, 13, 3, 5, 17,

\--/          \--/
9             15```

# FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

`\$seq = Math::NumSeq::AllPrimeFactors->new ()`
`\$seq = Math::NumSeq::AllPrimeFactors->new (order => \$str, multiplicity => \$str, on_values => \$str)`

Create and return a new sequence object.

`\$bool = \$seq->pred(\$value)`

Return true if `\$value` occurs in the sequence. This simply means `\$value` a prime, or for `on_values=>'odd'` an odd prime.

http://user42.tuxfamily.org/math-numseq/index.html