Math::NumSeq::PrimeFactorCount -- how many prime factors
use Math::NumSeq::PrimeFactorCount; my $seq = Math::NumSeq::PrimeFactorCount->new; my ($i, $value) = $seq->next;
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.
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
$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.
$value = $seq->ith($i)
Return the number of prime factors in $i
.
This calculation requires factorizing $i
and in the current code after small factors a hard limit of 2**32 is enforced in the interests of not going into a near-infinite loop.
$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
http://user42.tuxfamily.org/math-numseq/index.html
Copyright 2010, 2011, 2012, 2013, 2014 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/>.