Math::NumSeq::MobiusFunction -- Mobius function sequence
my $seq = Math::NumSeq::MobiusFunction->new;
my ($i, $value) = $seq->next;
The sequence of the Mobius function,
1, -1, -1, 0, -1, 1, ...
Each value is
1 if i has an even number of distinct prime factors
-1 if i has an odd number of distinct prime factors
0 if i has a repeated prime factor
The sequence starts from i=1 and it's reckoned as no prime factors, ie. 0 factors, which is considered even, hence value=1. Then i=2 and i=3 are value=-1 since they have one prime factor (they're primes), and i=4 is value=0 because it's 2*2 which is a repeated prime 2.
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
$seq = Math::NumSeq::MobiusFunction->new ()
Create and return a new sequence object.
$value = $seq->ith($i)
Return the Mobius function of $i, being 1, 0 or -1 according to the prime factors of $i.
This calculation requires factorizing $i and in the current code small primes are checked then a hard limit of 2**32 is placed on $i, in the interests of not going into a near-infinite loop.
$bool = $seq->pred($value)
Return true if $value occurs in the sequence, which means simply 1, 0 or -1.
Math::NumSeq, Math::NumSeq::LiouvilleFunction, Math::NumSeq::PrimeFactorCount
"moebius" in Math::Prime::Util
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/>.
To install Math::NumSeq, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.