Math::NumSeq::AlmostPrimes -- semiprimes and other fixed number of prime factors
use Math::NumSeq::AlmostPrimes; my $seq = Math::NumSeq::AlmostPrimes->new (factor_count => 2); my ($i, $value) = $seq->next;
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 => 2
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.
factor_count => $c
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.
multiplicity => 'distinct'
See "FUNCTIONS" in Math::NumSeq for the behaviour common to all path classes.
$seq = Math::NumSeq::AlmostPrimes->new (key=>value,...)
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.
$value
factor_count
distinct
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.
Math::NumSeq, Math::NumSeq::Primes, Math::NumSeq::PrimeFactorCount
Math::NumSeq::Primorials
To install Math::NumSeq, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::NumSeq
CPAN shell
perl -MCPAN -e shell install Math::NumSeq
For more information on module installation, please visit the detailed CPAN module installation guide.