1Math::NumSeq::KlarnerRaUdsoe(r3)Contributed Perl DocumenMtaatthi:o:nNumSeq::KlarnerRado(3)
2
3
4
6 Math::NumSeq::KlarnerRado -- Klarner-Rado sequences
7
9 use Math::NumSeq::KlarnerRado;
10 my $seq = Math::NumSeq::KlarnerRado->new;
11 my ($i, $value) = $seq->next;
12
14 Start with 1, then for any k in the sequence then 2*k, 3*k+2 and 6*k+3
15 are in the sequence too. Thus 1,2,4,5,8,9,etc.
16
18 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
19 classes.
20
21 "$seq = Math::NumSeq::KlarnerRado->new ()"
22 "$seq = Math::NumSeq::KlarnerRado->new (start => $n)"
23 Create and return a new sequence object.
24
25 The optional "start" parameter can start the sequence from a value
26 other than 1, which changes the sequence and in general bigger
27 values thin out the sequence.
28
29 "$bool = $seq->pred($value)"
30 Return true if $value occurs in the sequence.
31
33 Predicate
34 Taking value mod 6 can say whether it's a descendant of one of the 2*k,
35 3*k+2, 6*k+3 forms, and thus give one or two reduced values to then
36 check for being in the sequence.
37
38 value mod 6 descendant of reduce to
39 0 2k value/2
40 1 none
41 2 2k or 3k+2 value/2 and (value-2)/3
42 3 6k+3 (value-3)/6
43 4 2k value/2
44 5 3k+2 (value-2)/3
45
46 The reduction dividing out 2, 3 or 6 makes the test logarithmic, except
47 when 2mod6 gives two reduced values to check.
48
50 Math::NumSeq
51
53 <http://user42.tuxfamily.org/math-numseq/index.html>
54
56 Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
57
58 Math-NumSeq is free software; you can redistribute it and/or modify it
59 under the terms of the GNU General Public License as published by the
60 Free Software Foundation; either version 3, or (at your option) any
61 later version.
62
63 Math-NumSeq is distributed in the hope that it will be useful, but
64 WITHOUT ANY WARRANTY; without even the implied warranty of
65 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
66 General Public License for more details.
67
68 You should have received a copy of the GNU General Public License along
69 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
70
71
72
73perl v5.36.0 2023-01-20 Math::NumSeq::KlarnerRado(3)