Math::N...gitCount(3)
π Math::NumSeq::MaxDigitCount β NAME π
okay so bestie, this is Math::NumSeq::MaxDigitCount, and it does exactly what it says on the tin: it's the maximum count of a given digit in any radix. Periodt. The default digit we're hunting for is 0. π
β¨ SYNOPSIS β¨
use Math::NumSeq::MaxDigitCount;
my $seq = Math::NumSeq::MaxDigitCount->new (values_type => 'count');
my ($i, $value) = $seq->next;
π¦ DESCRIPTION π¦
So here's the vibe: take a number i, write it out in literally every radix you can, and find the biggest count of some chosen digit that shows up anywhere. That max count is your answer. Default digit is 0, iykyk.
0, 1, 1, 2, 1, 1, 1, 3, 2, 2, 1, 2, 1, 1, 1, 4, 3, 3, 2, ...
starting i=1
Not me explaining i=15 β it's 1 because 15 in ternary is "120" which has 1 zero, and no other base has more than that. Also lowkey iconic: i is "10" in base i itself, so there's always at least 1 zero once you're past i=1. π
πΈ Radix πΈ
Slap values_type => 'radix' on there and you get the radix where that max actually happens:
# values_type => "radix"
2, 2, 3, 2, 2, 2, 7, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, ...
If the max count shows up in more than one radix, you get the smallest one where it happens. And i=1? She has no zeros in any radix, so the return is 2 for binary β because the count 0 occurs in that radix. π€·βοΈ
π Digit π
digit => $n lets you pick a different digit to count, like:
# digit => 1
1, 1, 2, 2, 2, 2, 3, 2, 2, 2, 3, 2, 3, 3, 4, 2, 2, 2, 3, ...
Example for the girlies: at i=7 the count is 3, because 7 in binary is "111" β three digit 1s. ate. π₯
π FUNCTIONS π
For all the shared behaviour that every sequence class has, go peek at "FUNCTIONS" in Math::NumSeq.
$seq = Math::NumSeq::MaxDigitCount->new ()$seq = Math::NumSeq::MaxDigitCount->new (digit => $d, values_type => $str)
Both of these create and return a new sequence object for you. π«Ά
π Random Access π
$value = $seq->ith($i)β returns the count or the radix for the digit you selected, when$iis written in any radix.$bool = $seq->pred($value)β returns true if$valueoccurs in the sequence. Fr fr it just means$valueis an integer, but excluding0when you're seekingdigit=1, or excluding1when you're seeking the radix.
π SEE ALSO π
Math::NumSeqMath::NumSeq::DigitCount
β HOME PAGE β
<http://user42.tuxfamily.org/math-numseq/index.html>
π LICENSE π
Copyright 2012, 2013, 2014, 2016, 2019, 2020 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/>.
no cap, that's the whole page π written by the perl girlies,perl v5.42.0, dated2025-07-25. mwah. π β¨
π¦ where this page comes from
- fedora 43: perl-Math-NumSeq 75-11.fc43 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms