Math::N...bundant(3)

๐Ÿ“ฆ
version 75 ยท 2 versions
, in fedora 43

๐Ÿ’– Math::N...bundant(3) โ€” the abundant numbers manual, bestie edition ๐Ÿ’–

okay so real quick before we get into it: this is a page from the User Contributed Perl Documentation and the module is Math::N...bundant. yes the man page name is literally truncated with dots, it's giving "we ran out of space on the shelf" energy, but the module is Math::NumSeq::Abundant and she is iconic. sit down, hydrate, let's go ๐Ÿซถ


โœจ NAME โœจ

Math::NumSeq::Abundant โ€” abundant numbers, greater than sum of divisors ๐Ÿ’…

like. the numbers that are bigger than the sum of their own divisors. obsessed with the audacity honestly.


๐ŸŒธ SYNOPSIS ๐ŸŒธ

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

that's it, that's the whole vibe. make the object, call next, get your $i and your $value. periodt ๐Ÿ’œ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so the abundant numbers are the integers that are greater than the sum of their divisors, bestie:

12, 18, 20, 24, 30, 36, ...
starting i=1

okay wait let me show you why, because the math is genuinely cute. take 12. its divisors are 1,2,3,4,6 and if you add them all up you get 16. and 16 is > 12. so 12 is abundant. it's overflowing. it's got main character energy and then some. ๐Ÿ˜Œ

the way people usually write this is 2*n>sigma(n) where sigma(n) is the sum of divisors of n including n itself. so like, n plus all its proper divisors. yes, n counts. no, we're not debating it. ๐Ÿ™ˆ

๐Ÿ’€ Deficient ๐Ÿ’€

option abundant_type => "deficient" gives you the integers n where n < sum divisors:

abundant_type => "deficient"
1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13,

it's the opposite of abundant, lowkey โ€” except that the few perfect numbers where n == sum divisors get left out of both camps (go look at "Perfect Numbers" below, it's a whole thing). so these are the little guys who just can't even reach their own divisor sum. we love them anyway ๐Ÿ’–

๐ŸŽ€ Primitive Abundant ๐ŸŽ€

option abundant_type => "primitive" gives you abundant numbers that are not a multiple of some smaller abundant:

abundant_type => "primitive"
12, 18, 20, 30, 42, 56, 66, 70, 78, ...

here's the tea ๐Ÿ“: if an integer n is abundant then so are all its multiples 2*n, 3*n, 4*n, etc. the "primitive" abundants are the ones that are not such a multiple โ€” they're the originals, the trendsetters, the ones who started it.

option abundant_type => "non-primitive" is the other side: abundant numbers that are not primitive, i.e. they have a divisor that's also abundant.

abundant_type => "non-primitive"
24, 36, 40, 48, 54, 60, 72, 80, 84, ...

every abundant number is either primitive or non-primitive. there is no third option. that's the whole dichotomy, no cap. โœจ

๐Ÿ‘‘ Perfect Numbers ๐Ÿ‘‘

numbers where n == sum divisors are the perfect numbers: 6, 28, 496, 8128, 33550336, etc.

there's nothing here for them currently in this module โ€” they're just not implemented, sorry bestie ๐Ÿ˜ญ. they're also quite sparse, which, fair. Euler proved that the even ones are always n=2^(k-1)*(2^k-1) for prime 2^k-1 (those primes being the Mersenne primes, iconic name, iconic legacy). and whether any odd perfect numbers exist is a famous unsolved problem. if there are any odd perfect numbers then they're very big โ€” like, we've checked an absurd amount and found nothing, so they're out there hiding or they don't exist and we simply don't know. mysterious queen behavior ๐Ÿ’œ


๐Ÿ”ฅ FUNCTIONS ๐Ÿ”ฅ

go read "FUNCTIONS" in Math::NumSeq for the behaviour common to all sequence classes โ€” that's the shared lore, iykyk.

  • $seq = Math::NumSeq::Abundant->new ()
  • $seq = Math::NumSeq::Abundant->new (abundant_type => $str)

create and return a new sequence object, bestie. the abundant_type argument is a string and it can be:

"abundant"        n > sum divisors (the default)
"deficient"       n < sum divisors
"primitive"       abundant and not a multiple of an abundant
"non-primitive"   abundant and also a multiple of an abundant

so "abundant" is the default, no surprises. ๐Ÿ’…

  • $bool = $seq->pred($value)

returns true if $value is abundant, deficient or primitive abundant per $seq โ€” so it depends on which abundant_type you built the object with, got it?

โš ๏ธ heads up bestie: this check requires factorizing $value, and in the current code there's a hard limit of 2**32 placed on the values to be checked โ€” in the interests of not going into a near-infinite loop. so don't send it something huge and then act surprised. she's setting a boundary and honestly? respect. ๐Ÿซถ

๐ŸŒˆ FORMULAS ๐ŸŒˆ

๐Ÿงฎ Predicate ๐Ÿงฎ

for the prime factorization n=p^a * q^b * ... the divisors are all of

divisor = p^A * q^B * ...   for A=0 to a, B=0 to b, etc

and this includes n itself with A=a,B=b,etc. the sum is formed by grouping each with factor p^i, etc, and it all results in a product:

sigma =   (1 + p + p^2 + ... + p^a)
        * (1 + q + q^2 + ... + q^a)
        * ...

sigma = (p^(a+1)-1)/(p-1) * (q^(b+1)-1)/(q-1) * ...

so from the prime factorization of n, the sigma gets built and then compared against n:

sigma > 2*n      abundant
sigma < 2*n      deficient

two lines. that's the whole test. slay. โœจ

๐ŸŒŸ Predicate -- Primitive ๐ŸŒŸ

for primitive abundant we also need to know that no divisor of n is abundant.

and here's the smart part: for divisors of n it suffices to consider n reduced by a single prime, so n/p. because if taking out some non-prime like n/(p*q) gives an abundant, then so is n/p, since it's a multiple of n/(p*q). to test an n/p for abundance:

sigma(n/p) > 2*n/p     means have an abundant divisor

and sigma(n/p) can be calculated from sigma(n) by dividing out the p^a term described above and replacing it with the term for p^(a-1):

oldterm = (p^(a+1) - 1)/(p-1)
newterm = (p^a     - 1)/(p-1)

sigma(n) * newterm / oldterm > n/p
sigma(n) * p*newterm / oldterm > n

and p*newterm/oldterm simplifies down to:

sigma(n) * (1 - 1/oldterm) > n      means an abundant divisor

the left side is a maximum when the factor (1 - 1/oldterm) reduces sigma(n) by the least, and that's when oldterm is the biggest. so to test for primitive abundance, note the largest term in the sigma(n) calculation above:

if sigma(n) > 2*n
then n is abundant

if sigma(n) * (1-1/maxterm) > 2*n
then have an abundant divisor and so n is not primitive abundant

there it is. that's the whole trick. ๐Ÿงš


๐ŸŽ€ SEE ALSO ๐ŸŽ€

  • Math::NumSeq

go read it, it's the parent, it's the blueprint, it ate. ๐Ÿ’–


๐ŸŒ HOME PAGE ๐ŸŒ

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


๐Ÿ“œ LICENSE ๐Ÿ“œ

Copyright 2010, 2011, 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/>.

๐Ÿ’€ not me putting the all-caps warranty disclaimer in there but fr fr it means what it says, no warranty, that's not a vibe it's a legal fact.

and that's the whole page bestie, tysm for reading ๐Ÿ’… this was perl v5.42.0, dated 2025-07-25, and it's the Math::N...bundant(3) man page โ€” go forth and count your divisors, mwah ๐Ÿซถ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from