Math::N...unction(3)
π NAME π
Math::NumSeq::MobiusFunction β bestie, it's the Mobius function sequence β¨ (a user-contributed Perl thing, filed under Math::N...unction(3), iykyk)
π¦ SYNOPSIS π¦
use Math::NumSeq::MobiusFunction;
my $seq = Math::NumSeq::MobiusFunction->new;
my ($i, $value) = $seq->next;
okay so literally three lines and you're in π
πΈ DESCRIPTION πΈ
It's the sequence of the Mobius function, and here's the glow-up:
1, -1, -1, 0, -1, 1, ...
starting i=1
Each value is one of three things:
1β ifihas an even number of distinct prime factors-1β ifihas an odd number of distinct prime factors0β ifihas a repeated prime factor
The sequence starts from i=1 and, like, it's reckoned as having no prime factors β that's 0 factors β and 0 counts as even, so value 1. Then i=2 and i=3 are value -1 because they each have one prime factor (they're primes, periodt), and i=4 is value 0 because it's 2*2, aka a repeated prime 2 π
β¨ FUNCTIONS β¨
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes β that's the shared lore π«Ά
$seq = Math::NumSeq::MobiusFunction->new ()β create and return a new sequence object. Fresh object, new era π
π Random Access π
$value = $seq->ith($i)β return the Mobius function of$i, being1,0or-1according to the prime factors of$i.
ngl this calculation requires factorizing$i, and in the current code small primes are checked then a hard limit of2**32is placed on$iβ all in the interests of not going into a near-infinite loop π
$bool = $seq->pred($value)β return true if$valueoccurs in the sequence, which means simply1,0or-1. That's it, that's the whole vibe check.
π SEE ALSO π
Math::NumSeqMath::NumSeq::LiouvilleFunctionMath::NumSeq::PrimeFactorCount"moebius" in Math::Prime::Util
π§ 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/>.
and that's the whole page bestie, no cap π
β brought to you by perl v5.42.0, dated 2025-07-25, living in the Math::N...unction(3) corner of the manual. slay π
π¦ 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