Math::N...eFactors(3)
π Math::NumSeq::AllPrimeFactors π
okay bestie so this is a page from the User Contributed Perl Documentation for the module Math::NumSeq::AllPrimeFactors, and no it's not as scary as the name looks, I promise. it's literally just prime factors of the integers, one after another, like a lil parade. slay. β¨
πΈ NAME πΈ
Math::NumSeq::AllPrimeFactors β prime factors of the integers, periodt. π
β¨ SYNOPSIS β¨
use Math::NumSeq::AllPrimeFactors;
my $seq = Math::NumSeq::AllPrimeFactors->new;
my ($i, $value) = $seq->next;
that's it. that's the whole vibe. π¦
π DESCRIPTION π
so what this gives you is a list of the prime factors of the integers 2, 3, 4, etc. all of them. every single factor. no gatekeeping. π
starting i=1
2, 3, 2, 2, 5, 2, 3, 7, 2, 2, 2, 3, 3, 2, 5, 11, ...
\--/ \--/ \-----/ \--/ \--/
4 5 6 7 8 9 10 11
see how it lines up? 4 gives you 2, 2, 6 gives you 2, 3, 8 gives you 2, 2, 2, 12 would keep going, etc etc. iconic behaviour honestly. π
π« Order π«
there's an optional order parameter (a string, bestie, a string) that controls the order of the primes within each integer. your choices are:
"ascending"β the default, chill, normal, we love her"descending"
for example, "descending" rearranges the values to:
# order => "descending"
2, 3, 2, 2, 5, 3, 2, 7, 2, 2, 2, 3, 3, 5, 2, 11, ...
\--/ \--/ \-----/ \--/ \--/
4 5 6 7 8 9 10 11
the first difference shows up as 3, 2 for 6 (instead of 2, 3). yes she flipped it. main character energy. π
π§ Multiplicity π§
option multiplicity => "distinct" can give just one copy of each prime factor β like, no repeats, we're keeping it minimal:
# multiplicity => "distinct"
2, 3, 2, 5, 2, 3, 7, 2, 3, 2, 5, 11, ...
\--/ \--/
4 5 6 7 8 9 10 11
see, 8 used to be three 2s and now she's just one lil 2. so demure. π
πΈ On Values πΈ
option on_values can give the prime factors of just some integers, if you're feeling selective:
"all"β the default, everybody's invited"composites"β the non-primes from 4 onwards"odd"β odd integers 3 onwards"even"β even integers 2 onwards
real talk:"odd"is not simply a matter of filtering out 2s from the sequence. no ma'am. because it takes the other primes from the even integers too, such as the3from 6. iykyk. π
# on_values => "odd"
3, 5, 7, 3, 3, 11, 13, 3, 5, 17,
\--/ \--/
9 15
lowkey a trap if you assume things, fr fr. π
π₯ FUNCTIONS π₯
first off: go read "FUNCTIONS" in Math::NumSeq for the behaviour that's common to all sequence classes. that's the shared lore. π
$seq = Math::NumSeq::AllPrimeFactors->new ()$seq = Math::NumSeq::AllPrimeFactors->new (order => $str, multiplicity => $str, on_values => $str)
β Create and return a new sequence object. fresh out the box, ready to go. β¨
$bool = $seq->pred($value)
β Return true if $value occurs in the sequence. and what does that mean, bestie? it simply means $value is a prime, or for "on_values=>'odd'" an odd prime. that's it, that's the whole test. π―
π¦ SEE ALSO π¦
Math::NumSeqMath::NumSeq::PrimeFactorCountMath::NumSeq::AllDigits
the whole friend group, go say hi. π«Ά
β HOME PAGE β
<http://user42.tuxfamily.org/math-numseq/index.html>
(the link is right there, go click it, it's giving official.) π
π LICENSE π
Copyright 2012, 2013, 2014, 2016, 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/>.
okay and that's the whole page, bestie!! π this one's from perl v5.42.0, dated 2025-07-25 β so yes, she's recent, she's maintained, she's that girl. go factor some primes. mwah. ππΈπ
π¦ 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