1Math::NumSeq::FibbinaryUBsietrCoCuonntt(r3i)buted Perl DMoactuhm:e:nNtuamtSieoqn::FibbinaryBitCount(3)
2
3
4

NAME

6       Math::NumSeq::FibbinaryBitCount -- number of bits in each fibbinary
7       number
8

SYNOPSIS

10        use Math::NumSeq::FibbinaryBitCount;
11        my $seq = Math::NumSeq::FibbinaryBitCount->new;
12        my ($i, $value) = $seq->next;
13

DESCRIPTION

15       The number of 1 bits in the i'th fibbinary number.
16
17           0, 1, 1, 1, 2, 1, 2, 2, 1, 2, 2, 2, 3, 1, 2, 2, 2, 3, 2, ...
18           starting i=0
19
20       For example i=9 is Fibbinary "1001" so value=2 for 2 1-bits.
21
22       The count is 1 for the Fibonacci numbers, as they're "100..00" with a
23       single 1-bit in fibbinary.
24
25   Digit 0
26       Option "digit => "0"" counts instead the 0-bits
27
28           # digit=>"0"   starting i=0
29           0, 0, 1, 2, 1, 3, 2, 2, 4, 3, 3, 3, 2, 5, 4, 4, 4, 3, 4, ...
30
31       i=0 is considered to be an empty set of digits, so it has value=0.
32       This is the same as the "DigitCount" sequence treats i=0.
33
34   Digit 00
35       Option "digit => "00"" counts the 0-bits which don't follow a 1-bit,
36       which is equivalent to "00" pairs (including overlapping pairs).
37
38           # digit=>"00"   starting i=0
39           0, 0, 0, 1, 0, 2, 1, 0, 3, 2, 1, 1, 0, 4, 3, 2, 2, 1, 2, ...
40
41       For example i=42 is fibbinary "10010000" (42=34+8).  It has value=4 for
42       4 0-bits not counting the two which immediately follow the two 1-bits.
43       Or equivalently 4 "00" pairs
44
45                    v  vvv    four 0s which don't follow a 1
46           i=42   10010000
47                   ^^ ^^      four "00" pairs, overlaps allowed
48                       ^^
49                        ^^
50
51       Fibbinary numbers by definition never have consecutive 1-bits, so
52       there's always a 0 following a 1.  Excluding those leaves a count of
53       genuinely skipped positions.
54
55       When passing the "00" option don't forget to quote it as a string,
56       since a literal number 00 is an octal 0.
57
58           $seq = Math::NumSeq::FibbinaryBitCount->new (digit => "00");  # good
59           $seq = Math::NumSeq::FibbinaryBitCount->new (digit => 00);    # bad
60

FUNCTIONS

62       See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
63       classes.
64
65       "$seq = Math::NumSeq::FibbinaryBitCount->new ()"
66       "$seq = Math::NumSeq::FibbinaryBitCount->new (digit => $str)"
67           Create and return a new sequence object.
68
69   Random Access
70       "$value = $seq->ith($i)"
71           Return the bit count of the $i'th fibbinary number.
72
73       "$bool = $seq->pred($value)"
74           Return true if $value occurs as a bit count, which simply means
75           "$value >= 0".
76

SEE ALSO

78       Math::NumSeq, Math::NumSeq::Fibbinary, Math::NumSeq::DigitCount,
79       Math::NumSeq::Fibonacci
80

HOME PAGE

82       <http://user42.tuxfamily.org/math-numseq/index.html>
83

LICENSE

85       Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
86
87       Math-NumSeq is free software; you can redistribute it and/or modify it
88       under the terms of the GNU General Public License as published by the
89       Free Software Foundation; either version 3, or (at your option) any
90       later version.
91
92       Math-NumSeq is distributed in the hope that it will be useful, but
93       WITHOUT ANY WARRANTY; without even the implied warranty of
94       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
95       General Public License for more details.
96
97       You should have received a copy of the GNU General Public License along
98       with Math-NumSeq.  If not, see <http://www.gnu.org/licenses/>.
99
100
101
102perl v5.36.0                      2022-07-22Math::NumSeq::FibbinaryBitCount(3)
Impressum