NAME

Math::NumSeq::MaxDigitCount -- maximum count of a given digit in any radix

SYNOPSIS

use Math::NumSeq::MaxDigitCount;
my $seq = Math::NumSeq::MaxDigitCount->new (values_type => 'count');
my ($i, $value) = $seq->next;

DESCRIPTION

This is the maximum count of a given digit which occurs when i is written in any radix. The default digit is 0.

0, 1, 1, 2, 1, 1, 1, 3, 2, 2, 1, 2, 1, 1, 1, 4, 3, 3, 2, ...
starting i=1

For example i=15 is 1 because 15 = ternary "120" which has 1 zero, and no other base has more than that. i is "10" in base i itself so there's always at least 1 zero, after i=1.

Radix

Option values_type => 'radix' gives the radix where the maximum occurs,

# values_type => "radix"
2, 2, 3, 2, 2, 2, 7, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, ...

If the maximum count occurs in more than one radix the value is the smallest where it occurs. i=1 has no zeros in any radix and the return is 2 for binary since the count 0 occurs in that radix.

Digit

Option digit => $n selects another digit to count, for example

# digit => 1
1, 1, 2, 2, 2, 2, 3, 2, 2, 2, 3, 2, 3, 3, 4, 2, 2, 2, 3, ...

For example at i=7 the count is 3 since 7 in binary is "111" with 3 digit 1s.

FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

$seq = Math::NumSeq::MaxDigitCount->new ()
$seq = Math::NumSeq::MaxDigitCount->new (digit => $d, values_type => $str)

Create and return a new sequence object.

Random Access

$value = $seq->ith($i)

Return the count or radix for the selected digit when $i is written in any radix.

$bool = $seq->pred($value)

Return true if $value occurs in the sequence. This simply means $value an integer, but excluding 0 when seeking digit=1, or excluding 1 when seeking the radix.

SEE ALSO

Math::NumSeq, Math::NumSeq::DigitCount

HOME PAGE

http://user42.tuxfamily.org/math-numseq/index.html

LICENSE

Copyright 2012, 2013, 2014, 2016 Kevin Ryde

Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.