Math::N...mModulo(3)
π Math::N...mModulo(3) π
okay bestie, so this lil page comes from the User Contributed Perl Documentation manual (the title up top is a lil mangled as Math::N...mModulo(3), it's just giving truncated filename energy, we move π
). Sit down, grab a boba, and let's talk digit sums.
β¨ NAME β¨
Math::NumSeq::DigitSumModulo β digit sum taken modulo a given modulus. periodt.
πΈ SYNOPSIS πΈ
use Math::NumSeq::DigitSumModulo;
my $seq = Math::NumSeq::DigitSumModulo->new (radix => 10,
modulus => 9);
my ($i, $value) = $seq->next;
π¦ DESCRIPTION π¦
So basically: take each i, add up all its digits, and then take that sum modulo the radix or modulo a modulus you pick. That's the whole vibe.
Like fr fr, at i=123 with modulus 5 the value is 1+2+3=6, mod 5 = 1. Math is mathing. π
Modulus 0, which is the default, means modulo the radix. no cap, that's just what it does.
π Thue-Morse Sequence π
Okay this part is iconic. For "radix=>2, modulus=>2" this is the Thue-Morse "parity" sequence, being 1 if i has an odd number of 1 bits or 0 if an even number of 1 bits.
Numbers where it's 1 are sometimes called "odious" numbers ππ and where it's 0 called "evil" numbers. Not me learning that "evil numbers" is a real technical term. π
π FUNCTIONS π
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes. (Like, all the shared lore. iykyk.)
$seq = Math::NumSeq::DigitSumModulo->new (radix => $r, modulus => $d)β Create and return a new sequence object. main character constructor behavior, honestly.
π₯ Random Access π₯
$value = $seq->ith($i)β Return the sum of the digits in$iwritten in"radix", modulo the"modulus". yes bestie, random access, we're not looping from the start like a peasant.$bool = $seq->pred($value)β Return true if$valuemight occur as value in the sequence, which means simply$value = 0>and"$value <= modulus"(the given"modulus"or the"radix"if modulus=0). β¨
π SEE ALSO π
Math::NumSeqMath::NumSeq::DigitSumMath::NumSeq::MephistoWaltz
π§ HOME PAGE π§
<http://user42.tuxfamily.org/math-numseq/index.html>
π LICENSE π
Copyright 2011, 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/>.
and that's the whole page, babe π«Ά this was perl v5.42.0, dated 2025-07-25, filed under Math::N...mModulo(3). slay, go compute some digit sums π
β¨π
π¦ 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