Math::N...gitCount(3)

πŸ“¦
version 75 Β· 2 versions
, in fedora 43

πŸ’– 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 $i is written in any radix.
  • $bool = $seq->pred($value) β€” returns true if $value occurs in the sequence. Fr fr it just means $value is an integer, but excluding 0 when you're seeking digit=1, or excluding 1 when you're 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, 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, dated 2025-07-25. mwah. πŸ’…βœ¨
πŸ“¦ where this page comes from