++ed by:

2 PAUSE user(s)

Kevin Ryde


Math::NumSeq::PrimeFactorCount -- how many prime factors


 use Math::NumSeq::PrimeFactorCount;
 my $seq = Math::NumSeq::PrimeFactorCount->new;


The sequence of how many prime factors in i, being

    0, 1, 1, 2, 1, 2, ...

The sequence starts from i=1 and 1 is taken to have no prime factors. Then i=2 and i=3 are themselves primes, so 1 prime factor. Then i=4 is 2*2 which is 2 prime factors.

The multiplicity => "distinct" option can control whether repeats of a prime factors are counted, or only distinct primes. For example with "distinct" i=4=2*2 is just 1 prime factor.



$seq = Math::NumSeq::PrimeFactorCount->new ()
$seq = Math::NumSeq::PrimeFactorCount->new (multiplicity => $str, prime_type => $str)

Create and return a new sequence object.

Option multiplicity is a string either

    "repeated"      count repeats of primes (the default)
    "distinct"      count only distinct primes

Option prime_type is a string either

    "all"           count all primes
    "odd"           count only odd primes (ie. not 2)
    "4k+1"          count only primes 4k+1
    "4k+3"          count only primes 4k+3
    "twin"          count only twin primes
                      (P for which P+2 or P-2 also prime)
    "SG"            count only Sophie Germain primes
                      (P for which 2P+1 also prime)
    "safe"          count only "safe" primes
                      (P for which (P-1)/2 also prime)

"twin" counts both primes of each twin prime pair, so all of 3,5,7, 11,13, 17,19, etc.

Random Access

$value = $seq->ith($i)

Return the number of prime factors in $i.


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

Return true if $value occurs in the sequence, which means simply integer $value >= 0.


Math::NumSeq, Math::NumSeq::Primes, Math::NumSeq::TwinPrimes, Math::NumSeq::SophieGermainPrimes, Math::NumSeq::LiouvilleFunction, Math::NumSeq::MobiusFunction, Math::NumSeq::PowerFlip




Copyright 2010, 2011, 2012, 2013, 2014 Kevin Ryde


