1Math::NumSeq::LiouvilleUFsuenrctCioonnt(r3i)buted Perl DMoactuhm:e:nNtuamtSieoqn::LiouvilleFunction(3)
2
3
4
6 Math::NumSeq::LiouvilleFunction -- Liouville function sequence
7
9 use Math::NumSeq::LiouvilleFunction;
10 my $seq = Math::NumSeq::LiouvilleFunction->new;
11 my ($i, $value) = $seq->next;
12
14 The Liouville function parity of the prime factors of i,
15
16 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, ...
17 starting i=1
18
19 being
20
21 1 if i has an even number of prime factors
22 -1 if i has an odd number of prime factors
23
24 The sequence starts from i=1 which is taken to be no prime factors, ie.
25 zero, which is even, hence value 1. Then i=2 and i=3 are -1 since they
26 have one prime factor (they're primes), and i=4 is value 1 because it's
27 2*2 which is an even number of prime factors (two 2s).
28
29 This parity is similar to the "MobiusFunction", but here repeated prime
30 factors are included, whereas in "MobiusFunction" they give a value 0.
31
32 Values Type
33 The "values_type" parameter can change the two values returned for even
34 or odd prime factors. "0,1" gives 0 for even and 1 for odd, the same
35 as the count mod 2,
36
37 values_type => '0,1'
38 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, ...
39
40 Or "1,0" the other way around, 1 for even, 0 for odd,
41
42 values_type => '1,0'
43 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, ...
44
46 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
47 classes.
48
49 "$seq = Math::NumSeq::LiouvilleFunction->new ()"
50 "$seq = Math::NumSeq::LiouvilleFunction->new (values_type => $str)"
51 Create and return a new sequence object. Optional "values_type" (a
52 string) can be
53
54 "1,-1" 1=even, -1=odd (the default)
55 "0,1" 0=even, 1=odd
56 "1,0" 1=even, 0=odd
57
58 Random Access
59 "$value = $seq->ith($i)"
60 Return the Liouville function of $i, being 1 or -1 (or other
61 "values_type") according to the number of prime factors in $i.
62
63 This calculation requires factorizing $i and in the current code
64 after small factors a hard limit of 2**32 is enforced in the
65 interests of not going into a near-infinite loop.
66
67 "$bool = $seq->pred($value)"
68 Return true if $value occurs in the sequence, which simply means 1
69 or -1, or the two "values_type" values.
70
72 Math::NumSeq, Math::NumSeq::MobiusFunction,
73 Math::NumSeq::PrimeFactorCount
74
76 <http://user42.tuxfamily.org/math-numseq/index.html>
77
79 Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
80
81 Math-NumSeq is free software; you can redistribute it and/or modify it
82 under the terms of the GNU General Public License as published by the
83 Free Software Foundation; either version 3, or (at your option) any
84 later version.
85
86 Math-NumSeq is distributed in the hope that it will be useful, but
87 WITHOUT ANY WARRANTY; without even the implied warranty of
88 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
89 General Public License for more details.
90
91 You should have received a copy of the GNU General Public License along
92 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
93
94
95
96perl v5.36.0 2022-07-22Math::NumSeq::LiouvilleFunction(3)