Math::N...tPrimes(3)

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

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 $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. like, it will simply not go there πŸ’€

✨ SEE ALSO ✨

  • Math::NumSeq
  • Math::NumSeq::Primes
  • Math::NumSeq::PrimeFactorCount
  • Math::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