1Math::NumSeq::PrimeFactUosreCrouCnotn(t3r)ibuted Perl DoMcautmhe:n:tNautmiSoenq::PrimeFactorCount(3)
2
3
4
6 Math::NumSeq::PrimeFactorCount -- how many prime factors
7
9 use Math::NumSeq::PrimeFactorCount;
10 my $seq = Math::NumSeq::PrimeFactorCount->new;
11 my ($i, $value) = $seq->next;
12
14 The sequence of how many prime factors in i, being
15
16 0, 1, 1, 2, 1, 2, ...
17
18 The sequence starts from i=1 and 1 is taken to have no prime factors.
19 Then i=2 and i=3 are themselves primes, so 1 prime factor. Then i=4 is
20 2*2 which is 2 prime factors.
21
22 The "multiplicity => "distinct"" option can control whether repeats of
23 a prime factors are counted, or only distinct primes. For example with
24 "distinct" i=4=2*2 is just 1 prime factor.
25
27 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
28 classes.
29
30 "$seq = Math::NumSeq::PrimeFactorCount->new ()"
31 "$seq = Math::NumSeq::PrimeFactorCount->new (multiplicity => $str,
32 prime_type => $str)"
33 Create and return a new sequence object.
34
35 Option "multiplicity" is a string either
36
37 "repeated" count repeats of primes (the default)
38 "distinct" count only distinct primes
39
40 Option "prime_type" is a string either
41
42 "all" count all primes
43 "odd" count only odd primes (ie. not 2)
44 "4k+1" count only primes 4k+1
45 "4k+3" count only primes 4k+3
46 "twin" count only twin primes
47 (P for which P+2 or P-2 also prime)
48 "SG" count only Sophie Germain primes
49 (P for which 2P+1 also prime)
50 "safe" count only "safe" primes
51 (P for which (P-1)/2 also prime)
52
53 "twin" counts both primes of each twin prime pair, so all of 3,5,7,
54 11,13, 17,19, etc.
55
56 Random Access
57 "$value = $seq->ith($i)"
58 Return the number of prime factors in $i.
59
60 This calculation requires factorizing $i and in the current code
61 after small factors a hard limit of 2**32 is enforced in the
62 interests of not going into a near-infinite loop.
63
64 "$bool = $seq->pred($value)"
65 Return true if $value occurs in the sequence, which means simply
66 integer "$value >= 0".
67
69 Math::NumSeq, Math::NumSeq::Primes, Math::NumSeq::TwinPrimes,
70 Math::NumSeq::SophieGermainPrimes, Math::NumSeq::LiouvilleFunction,
71 Math::NumSeq::MobiusFunction, Math::NumSeq::PowerFlip
72
74 <http://user42.tuxfamily.org/math-numseq/index.html>
75
77 Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2018, 2019, 2020 Kevin
78 Ryde
79
80 Math-NumSeq is free software; you can redistribute it and/or modify it
81 under the terms of the GNU General Public License as published by the
82 Free Software Foundation; either version 3, or (at your option) any
83 later version.
84
85 Math-NumSeq is distributed in the hope that it will be useful, but
86 WITHOUT ANY WARRANTY; without even the implied warranty of
87 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
88 General Public License for more details.
89
90 You should have received a copy of the GNU General Public License along
91 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
92
93
94
95perl v5.34.1 2022-06-06 Math::NumSeq::PrimeFactorCount(3)