1Math::NumSeq::AllPrimeFUascetrorCso(n3t)ributed Perl DocMuamtehn:t:aNtuimoSneq::AllPrimeFactors(3)
2
3
4
6 Math::NumSeq::AllPrimeFactors -- prime factors of the integers
7
9 use Math::NumSeq::AllPrimeFactors;
10 my $seq = Math::NumSeq::AllPrimeFactors->new;
11 my ($i, $value) = $seq->next;
12
14 This is a list of the prime factors of the integers 2, 3, 4, etc
15
16 starting i=1
17 2, 3, 2, 2, 5, 2, 3, 7, 2, 2, 2, 3, 3, 2, 5, 11, ...
18
19 \--/ \--/ \-----/ \--/ \--/
20 4 5 6 7 8 9 10 11
21
22 Order
23 The optional "order" parameter (a string) can control the order of the
24 primes within each integer,
25
26 "ascending" the default
27 "descending"
28
29 For example "descending" rearranges the values to
30
31 # order => "descending"
32 2, 3, 2, 2, 5, 3, 2, 7, 2, 2, 2, 3, 3, 5, 2, 11, ...
33
34 \--/ \--/ \-----/ \--/ \--/
35 4 5 6 7 8 9 10 11
36
37 The first difference is 3,2 for 6 (instead of 2,3).
38
39 Multiplicity
40 Option "multiplicity => "distinct"" can give just one copy of each
41 prime factor.
42
43 # multiplicity => "distinct"
44 2, 3, 2, 5, 2, 3, 7, 2, 3, 2, 5, 11, ...
45
46 \--/ \--/
47 4 5 6 7 8 9 10 11
48
49 On Values
50 Option "on_values" can give the prime factors of just some integers,
51
52 "all" the default
53 "composites" the non-primes from 4 onwards
54 "odd" odd integers 3 onwards
55 "even" even integers 2 onwards
56
57 "odd" is not simply a matter of filtering out 2s from the sequence,
58 since it takes the other primes from the even integers too, such as the
59 3 from 6.
60
61 # on_values => "odd"
62 3, 5, 7, 3, 3, 11, 13, 3, 5, 17,
63
64 \--/ \--/
65 9 15
66
68 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
69 classes.
70
71 "$seq = Math::NumSeq::AllPrimeFactors->new ()"
72 "$seq = Math::NumSeq::AllPrimeFactors->new (order => $str, multiplicity
73 => $str, on_values => $str)"
74 Create and return a new sequence object.
75
76 "$bool = $seq->pred($value)"
77 Return true if $value occurs in the sequence. This simply means
78 $value a prime, or for "on_values=>'odd'" an odd prime.
79
81 Math::NumSeq, Math::NumSeq::PrimeFactorCount, Math::NumSeq::AllDigits
82
84 <http://user42.tuxfamily.org/math-numseq/index.html>
85
87 Copyright 2012, 2013, 2014, 2016 Kevin Ryde
88
89 Math-NumSeq is free software; you can redistribute it and/or modify it
90 under the terms of the GNU General Public License as published by the
91 Free Software Foundation; either version 3, or (at your option) any
92 later version.
93
94 Math-NumSeq is distributed in the hope that it will be useful, but
95 WITHOUT ANY WARRANTY; without even the implied warranty of
96 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
97 General Public License for more details.
98
99 You should have received a copy of the GNU General Public License along
100 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
101
102
103
104perl v5.30.1 2020-01-30 Math::NumSeq::AllPrimeFactors(3)