Math::N...igitSum(3)

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

πŸ’– Math::NumSeq::DigitSum β€” bestie edition πŸ’–

okay so this is a page from the User Contributed Perl Documentation manual, and it's all about Math::NumSeq::DigitSum, which is literally the sum of the digits of a number, and sometimes the digits get powered too. we love a math glow-up ✨


🌸 NAME 🌸

Math::NumSeq::DigitSum β€” sum of digits, possibly with powering πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

use Math::NumSeq::DigitSum;
my $seq = Math::NumSeq::DigitSum->new (radix => 10);
my ($i, $value) = $seq->next;

that's it, that's the whole vibe check πŸ¦‹


✨ DESCRIPTION ✨

so basically, for every i, you get the sum of its digits. so the sequence goes 0,1,...,9,1,2,..., etc. and like, at i=123 the value is 1+2+3=6. math ate, no cap πŸ’…


🫢 FUNCTIONS 🫢

peep "FUNCTIONS" in Math::NumSeq for the behaviour that's common to all the sequence classes, because they all share the same group chat.

  • $seq = Math::NumSeq::DigitSum->new ()
  • $seq = Math::NumSeq::DigitSum->new (radix => $r, power => $p)

make a brand new sequence object and hand it back to you 🎁. the default is decimal, with no powering, or you can pass the radix and/or power parameters if you want to customize the whole situation.

🌈 Random Access 🌈

  • $value = $seq->ith($i) β€” returns the sum of the digits of $i, with each digit raised to the given power parameter. yes, raised. it's giving glow-up πŸ’…
  • $bool = $seq->pred($value) β€” returns true if $value ever shows up as a sum of digits, which honestly just means "$value >= 0". that's the whole test. iconic behaviour honestly 😭

πŸ’œ SEE ALSO πŸ’œ

  • Math::NumSeq
  • Math::NumSeq::DigitLength
  • Math::NumSeq::DigitProduct
  • Math::NumSeq::DigitSumModulo

the whole friend group, obsessed 🫢


🌸 HOME PAGE 🌸

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

go say hi πŸ‘‘


πŸ‘‘ 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/>.

fr fr, that's the legal bit and it's not a joke β€” no warranty, periodt πŸ’€

and that's the page bestie!! this one's running on perl v5.42.0, dated 2025-07-25, and the whole thing was brought to you by Math::N...igitSum(3). stay slay, go sum some digits πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from