1Math::NumSeq::MobiusFunUcsteironC(o3n)tributed Perl DocuMmaetnht:a:tNiuomnSeq::MobiusFunction(3)
2
3
4
6 Math::NumSeq::MobiusFunction -- Mobius function sequence
7
9 use Math::NumSeq::MobiusFunction;
10 my $seq = Math::NumSeq::MobiusFunction->new;
11 my ($i, $value) = $seq->next;
12
14 The sequence of the Mobius function,
15
16 1, -1, -1, 0, -1, 1, ...
17 starting i=1
18
19 Each value is
20
21 1 if i has an even number of distinct prime factors
22 -1 if i has an odd number of distinct prime factors
23 0 if i has a repeated prime factor
24
25 The sequence starts from i=1 and it's reckoned as no prime factors, ie.
26 0 factors, which is considered even, hence value=1. Then i=2 and i=3
27 are value=-1 since they have one prime factor (they're primes), and i=4
28 is value=0 because it's 2*2 which is a repeated prime 2.
29
31 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
32 classes.
33
34 "$seq = Math::NumSeq::MobiusFunction->new ()"
35 Create and return a new sequence object.
36
37 Random Access
38 "$value = $seq->ith($i)"
39 Return the Mobius function of $i, being 1, 0 or -1 according to the
40 prime factors of $i.
41
42 This calculation requires factorizing $i and in the current code
43 small primes are checked then a hard limit of 2**32 is placed on
44 $i, in the interests of not going into a near-infinite loop.
45
46 "$bool = $seq->pred($value)"
47 Return true if $value occurs in the sequence, which means simply 1,
48 0 or -1.
49
51 Math::NumSeq, Math::NumSeq::LiouvilleFunction,
52 Math::NumSeq::PrimeFactorCount
53
54 "moebius" in Math::Prime::Util
55
57 <http://user42.tuxfamily.org/math-numseq/index.html>
58
60 Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
61
62 Math-NumSeq is free software; you can redistribute it and/or modify it
63 under the terms of the GNU General Public License as published by the
64 Free Software Foundation; either version 3, or (at your option) any
65 later version.
66
67 Math-NumSeq is distributed in the hope that it will be useful, but
68 WITHOUT ANY WARRANTY; without even the implied warranty of
69 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
70 General Public License for more details.
71
72 You should have received a copy of the GNU General Public License along
73 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
74
75
76
77perl v5.36.0 2023-01-20 Math::NumSeq::MobiusFunction(3)