and 1 contributors

# NAME

Math::NumSeq::AlmostPrimes -- semiprimes and other fixed number of prime factors

# SYNOPSIS

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

# DESCRIPTION

The sequence of numbers having a given number of prime factors. The default is the semiprimes `factor_count => 2` giving products of two primes P*Q, which is 4,6,9,10,14,15,etc. For example 15 because 15=3*5.

`factor_count => \$c` controls how many prime factors are to be used. 1 is the primes themselves (the same as Math::NumSeq::Primes). Or for example factor count 4 the sequence is 16,24,36,40,54,60,etc, eg. 60=2*2*3*5.

`multiplicity => 'distinct'` asks for products of distinct primes. For the default 2 factors this means no squares like 4=2*2, leaving 6,10,14,15,21,etc. For other factor count it eliminates any repeated factors, so for example factor count 4 becomes 210,330,390,462,510,546,etc. The first in the sequence is the primorial 2*3*5*7=210.

# FUNCTIONS

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

`\$seq = Math::NumSeq::AlmostPrimes->new ()`

Create and return a new sequence object.

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

Return true if `\$value` is an almost-prime, ie. it has exactly `factor_count` many prime factors, and if `distinct` is true then all those factors different.

This check requires factorizing `\$value` and in the current code a hard limit of 2**32 is placed on values to be checked, in the interests of not going into a near-infinite loop.

# SEE ALSO

Math::NumSeq::Primorials

# HOME PAGE

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

# LICENSE

Copyright 2010, 2011, 2012, 2013 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/>.