1Math::NumSeq::KolakoskiU(s3e)r Contributed Perl DocumentaMtaitohn::NumSeq::Kolakoski(3)
2
3
4
6 Math::NumSeq::Kolakoski -- sequence of 1s and 2s its own run lengths
7
9 use Math::NumSeq::Kolakoski;
10 my $seq = Math::NumSeq::Kolakoski->new;
11 my ($i, $value) = $seq->next;
12
14 The Kolakoski sequence is
15
16 i = 1 2 3 4 5 6 7 8 9
17 value = 1, 2, 2, 1, 1, 2, 1, 2, 2, ... (OEIS A000002)
18
19 where the values are 1 or 2 and the run lengths of 1s or 2s are given
20 by the sequence values themselves.
21
22 |-| |--| |--| |-||-| |--|
23 1, 2, 2, 1, 1, 2, 1, 2, 2, ... values
24 run length 1 2 2 1 1 2 ... lengths are values again
25
27 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
28 classes.
29
30 "$seq = Math::NumSeq::Kolakoski->new ()"
31 Create and return a new sequence object.
32
34 There's no need to keep the entire sequence, nor even the portion
35 between where i is up to and the values past that which those up to i
36 induce. Instead the value at i is determined by the earlier value,
37 which is determined a yet earlier value, etc. At each level only a
38 value and pending count need to be kept. The levels required end up
39 being about log base 1.6 of the position i.
40
42 Math::NumSeq, Math::NumSeq::GolombSequence
43
45 <http://user42.tuxfamily.org/math-numseq/index.html>
46
48 Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020, 2021 Kevin Ryde
49
50 Math-NumSeq is free software; you can redistribute it and/or modify it
51 under the terms of the GNU General Public License as published by the
52 Free Software Foundation; either version 3, or (at your option) any
53 later version.
54
55 Math-NumSeq is distributed in the hope that it will be useful, but
56 WITHOUT ANY WARRANTY; without even the implied warranty of
57 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
58 General Public License for more details.
59
60 You should have received a copy of the GNU General Public License along
61 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
62
63
64
65perl v5.36.0 2023-01-20 Math::NumSeq::Kolakoski(3)