Math::N...orCount(3)

πŸ“¦
version 75 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

Math::NumSeq::PrimeFactorCount β€” bestie, it's literally just "how many prime factors" πŸ’…


✨ SYNOPSIS ✨

use Math::NumSeq::PrimeFactorCount;
my $seq = Math::NumSeq::PrimeFactorCount->new;
my ($i, $value) = $seq->next;

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this is the sequence of how many prime factors are hanging out in i, and it goes like this:

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

The sequence starts from i=1, and 1 is taken to have no prime factors β€” like, zero, nothing, empty, it's giving "no thoughts head empty" 🫢. Then i=2 and i=3 are themselves primes, so they each get 1 prime factor. Then i=4 is 2*2, which is 2 prime factors. slay.

The "multiplicity => "distinct"" option can control whether repeats of a prime factors are counted, or only distinct primes. So for example with "distinct", i=4=2*2 is just 1 prime factor. no repeats, we're being picky, we're being ✨exclusive✨.


πŸ‘‘ FUNCTIONS πŸ‘‘

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, fresh out of the box, iconic behavior only.

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. both of them get counted, they're a package deal fr fr πŸ‘―

🌈 Random Access 🌈

  • $value = $seq->ith($i) β€” return the number of prime factors in $i.
⚠️ heads up bestie: 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. so like, no, we are not doing that today πŸ’€
  • $bool = $seq->pred($value) β€” return true if $value occurs in the sequence, which means simply integer "$value >= 0". that's it. that's the whole vibe check. βœ…

🌸 SEE ALSO 🌸

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


πŸŽ€ HOME PAGE πŸŽ€

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


πŸ’œ LICENSE πŸ’œ

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


and that's the whole page bestie!! this was Math::N...orCount(3) from the User Contributed Perl Documentation girlies, running on perl v5.42.0, dated 2025-07-25 πŸ’–βœ¨ go forth and count your primes, mwah 🫢

πŸ“¦ where this page comes from