1Math::NumSeq::MephistoWUasletrz(C3o)ntributed Perl DocumMeanttha:t:iNounmSeq::MephistoWaltz(3)
2
3
4
6 Math::NumSeq::MephistoWaltz -- Mephisto waltz sequence
7
9 use Math::NumSeq::MephistoWaltz;
10 my $seq = Math::NumSeq::MephistoWaltz->new;
11 my ($i, $value) = $seq->next;
12
14 This sequence is the Mephisto waltz, being the count mod 2 of ternary
15 digit 2s in i.
16
17 0,0,1, 0,0,1, 1,1,0, ... (A064990)
18 starting i=0
19
20 i=0 has no 2s so value=0, and likewise i=1 value=0. Then i=2 has one 2
21 so value=1.
22
23 The sequence can also be expressed as a morphism starting from single
24 term 0 and repeatedly expanding
25
26 0 -> 0,0,1
27 1 -> 1,1,0
28
29 So
30
31 0
32 0,0,1
33 0,0,1, 0,0,1, 1,1,0,
34 0,0,1, 0,0,1, 1,1,0, 0,0,1, 0,0,1, 1,1,0, 1,1,0, 1,1,0, 0,0,1
35
36 | original | | copy | | 0<->1 flipped |
37 +-----------------+ +-----------------+ +-----------------+
38
39 The effect of the expansion is keep the first third the same, append a
40 copy of it, and append an 0<->1 flipped copy of it .
41
43 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
44 classes.
45
46 "$seq = Math::NumSeq::MephistoWaltz->new ()"
47 Create and return a new sequence object.
48
49 Random Access
50 "$value = $seq->ith($i)"
51 Return the $i'th MephistoWaltz value, being the count mod 2 of the
52 ternary digit 2s in $i.
53
54 "$bool = $seq->pred($value)"
55 Return true if $value occurs in the sequence, which simply means 0
56 or 1.
57
59 The calculation can also be made in a power-of-3 base like 9, 27, 81,
60 etc instead of just 3. For example in base 9 digits 2, 5, 6, 7 have a
61 one (mod 2) ternary 2. These base 9 digits correspond to the 1s in the
62 initial sequence 0,0,1, 0,0,1, 1,1,0 shown above.
63
65 Math::NumSeq, Math::NumSeq::DigitSumModulo
66
68 <http://user42.tuxfamily.org/math-numseq/index.html>
69
71 Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
72
73 Math-NumSeq is free software; you can redistribute it and/or modify it
74 under the terms of the GNU General Public License as published by the
75 Free Software Foundation; either version 3, or (at your option) any
76 later version.
77
78 Math-NumSeq is distributed in the hope that it will be useful, but
79 WITHOUT ANY WARRANTY; without even the implied warranty of
80 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
81 General Public License for more details.
82
83 You should have received a copy of the GNU General Public License along
84 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
85
86
87
88perl v5.38.0 2023-07-20 Math::NumSeq::MephistoWaltz(3)