Math::N...Function(3)
π Math::NumSeq::LiouvilleFunction β the manual page, bestie edition π
okay so this is the user-contributed Perl documentation for Math::NumSeq::LiouvilleFunction(3), and honestly? it's giving math girlie energy and i'm obsessed. sit down, grab a snack, we're doing number theory π
β¨ NAME β¨
Math::NumSeq::LiouvilleFunction β the Liouville function sequence. that's it, that's the name, iconic π
π SYNOPSIS π
use Math::NumSeq::LiouvilleFunction;
my $seq = Math::NumSeq::LiouvilleFunction->new;
my ($i, $value) = $seq->next;
literally three lines and you're in. we love a low-effort entry point π«Ά
π¦ DESCRIPTION π¦
so the Liouville function is the parity of the prime factors of i, and it goes like this:
1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, ...
starting i=1
and the meaning of each value is:
1 if i has an even number of prime factors
-1 if i has an odd number of prime factors
the sequence starts at i=1, which we just decide has no prime factors, aka zero prime factors, and zero is even, so boom: value 1. then i=2 and i=3 are both -1 because each has exactly one prime factor (they're primes, bestie, they're literally primes). and i=4 is value 1 because it's 2*2, which is an even number of prime factors (two 2s, no cap) β¨
this parity is similar to "MobiusFunction", but here's the tea: with this one, repeated prime factors are included, whereas in "MobiusFunction" repeated factors give a value 0. different function, different vibe, don't mix them up π
π Values Type π
the "values_type" parameter can change the two values that get returned for even or odd prime factors. "0,1" gives 0 for even and 1 for odd, which is the same thing as the count mod 2:
values_type => '0,1'
0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, ...
or "1,0" flips it the other way around, 1 for even and 0 for odd:
values_type => '1,0'
1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, ...
π FUNCTIONS π
see "FUNCTIONS" in Math::NumSeq for the behaviour that's common to all sequence classes, because sharing is caring π
$seq = Math::NumSeq::LiouvilleFunction->new ()$seq = Math::NumSeq::LiouvilleFunction->new (values_type => $str)
create and return a new sequence object, slay. the optional "values_type" (a string, bestie, it's a string) can be:
"1,-1" 1=even, -1=odd (the default)
"0,1" 0=even, 1=odd
"1,0" 1=even, 0=odd
π§ Random Access π§
$value = $seq->ith($i)β return the Liouville function of$i, being1or-1(or whatever other"values_type"you picked) according to how many prime factors$ihas.
heads up: this calculation requires factorizing$i, and in the current code, after small factors, a hard limit of2**32is enforced. the reason? so it doesn't wander off into a near-infinite loop. we're not doing that today, no thank you π
$bool = $seq->pred($value)β return true if$valueoccurs in the sequence, which simply means1or-1, or the two"values_type"values. easy peasy β
π SEE ALSO π
Math::NumSeqMath::NumSeq::MobiusFunctionMath::NumSeq::PrimeFactorCount
πΈ HOME PAGE πΈ
<http://user42.tuxfamily.org/math-numseq/index.html>
π LICENSE π
Copyright 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/>.
and that's the whole page, bestie!! this absolute queen of a manpage is served up by perl v5.42.0 and it's dated 2025-07-25 β go forth and compute parities, you've got this π β¨π¦
π¦ 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