Math::N...tPrimes(3)
Math::N...tPrimes(3) π
okay bestie so this is a page from the User Contributed Perl Documentation and it's literally all about Math::NumSeq::AlmostPrimes β pull up a chair, we're doing number theory π
β¨ NAME β¨
Math::NumSeq::AlmostPrimes β semiprimes and other fixed number of prime factors π¦
β¨ SYNOPSIS β¨
like, the whole vibe in four lines:
use Math::NumSeq::AlmostPrimes;
my $seq = Math::NumSeq::AlmostPrimes->new (factor_count => 2);
my ($i, $value) = $seq->next;
β¨ DESCRIPTION β¨
So this sequence is all about the "almost prime" numbers β numbers that have a given number of prime factors. The default is 2 prime factors, and those cuties are the semi-primes. Like 15, because 15=3*5. iconic behavior fr π
4, 6, 9, 10, 14, 15, 21, 22, 25, 26, 33, 34, 35, ...
# starting i=1
πΈ Factor Count πΈ
factor_count => $c controls how many prime factors are to be used. 1 would be the primes themselves (the same as Math::NumSeq::Primes). Or for example factor count 4 is as follows. 60 is present because 60=2*2*3*5 has precisely 4 prime factors. no cap, it's just built different π
# factor_count => 4
16, 24, 36, 40, 54, 60, ...
The first number in the sequence is 2^factor_count, being prime factor 2 repeated factor_count many times. periodt π
π¦ Multiplicity π¦
multiplicity => 'distinct' asks for products of distinct primes. For the default factor count 2 this means exclude squares like 4=2*2, which leaves
# multiplicity => 'distinct'
6, 10, 14, 15, 21, ...
For other factor counts, multiplicity "distinct" eliminates any numbers with repeated factors, leaving only square-free numbers. For example factor count 4 becomes
# factor_count => 4, multiplicity => 'distinct'
210, 330, 390, 462, 510, 546, ...
For multiplicity "distinct" the first value in the sequence is a primorial (see Math::NumSeq::Primorials), being the first "factor_count" many primes multiplied together. For example 210 above is primorial 2*3*5*7. math ate that π
β¨ FUNCTIONS β¨
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes. (group project energy, they all share it π«Ά)
$seq = Math::NumSeq::AlmostPrimes->new ()$seq = Math::NumSeq::AlmostPrimes->new (factor_count => $integer, multiplicity => $str)
Create and return a new sequence object. "multiplicity" can be
"repeated" repeated primes allowed (the default)
"distinct" all primes must be distinct
$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.
β οΈ heads up bestie: this check requires factorizing$valueand in the current code a hard limit of2**32is placed on values to be checked, in the interests of not going into a near-infinite loop. like, it will simply not go there π
β¨ SEE ALSO β¨
Math::NumSeqMath::NumSeq::PrimesMath::NumSeq::PrimeFactorCountMath::NumSeq::Primorials
β¨ HOME PAGE β¨
<http://user42.tuxfamily.org/math-numseq/index.html> π go say hi
β¨ 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, you're so welcome π this was perl v5.42.0, dated 2025-07-25, and yes it really is that Math::N...tPrimes(3) at the top β the man page name got truncated and honestly? it's giving mysterious. anyway slay, go factor something πβ¨
π¦ where this page comes from
- fedora 43: perl-Math-NumSeq 75-11.fc43 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms