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.

SEE ALSO

Math::NumSeq, Math::NumSeq::PrimeFactorCount, Math::NumSeq::AllDigits

HOME PAGE

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

LICENSE

Copyright 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde

Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.