and 1 contributors

# 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.

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

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.

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.