Math::N...eFactors(3)

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

πŸ’– 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 the 3 from 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::NumSeq
  • Math::NumSeq::PrimeFactorCount
  • Math::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