Math::N...uctSteps(3)
β¨ NAME β¨
Math::NumSeq::DigitProductSteps β multiplicative persistence and digital root π
okay so bestie, this is a Perl thing from the User Contributed Perl Documentation, and it's genuinely so cute once you get it, i promise π«Ά
πΈ SYNOPSIS πΈ
use Math::NumSeq::DigitProductSteps;
my $seq = Math::NumSeq::DigitProductSteps->new (values_type => 'count');
my ($i, $value) = $seq->next;
that's it. that's the whole vibe check. make a sequence object, call next on it, get back an index and a value. iconic β¨
π¦ DESCRIPTION π¦
so what this thing does is it keeps multiplying the digits of a number together until you're left with a single digit. and the sequence values? they're the count of steps it took to get there. that count has a fancy name: the multiplicative persistence π
0,0,..0,0,1,1,..1,1,2,2,2,2,2,1,1,1,1,2,2,2,2,2,3,1,1,1,2,...
starting i=0
like, take i=39. it goes 3*9=27 β 2*7=14 β 1*4=4 to reach a single digit, so the value is 3 iterations. three whole steps, main character energy π
then if you pass values_type => 'root' you get the final digit you landed on instead, which is called the multiplicative digital root π
values_type => 'root'
0,1,2,...,9,0,1,...,9,0,2,4,6,8,0,2,4,6,8,0,3,6,9,2,5,8,...
and here's the tea:
i=0throughi=9are already single digits, so their count is0and their root is just the value itself. no work needed, slay πi=10toi=19all take just a single iteration to reach a single digit.i=25is the first one that needs2iterations. not me being dramatic abouti=25but it IS the first ok π
more lore: any i with a 0 digit takes just one iteration to get to root 0. and any i like 119111 β all 1s except for at most a single non-1 β also takes just one iteration. this includes the repunits 111..11 β¨ (yes bestie, repunits are a real word and they're kinda iconic)
π Radix π
there's an optional radix parameter that picks a base other than decimal, if you're feeling spicy πΆοΈ
binary radix=>2 is not very interesting tho, sorry β the digit product is always either 0 or 1. i>=2 always takes just 1 iteration and has root 0, except for i=2^k-1 which is all 1s and has root 1. that's the whole binary situation. lowkey uneventful but we respect it π«‘
π FUNCTIONS π
peep "FUNCTIONS" in Math::NumSeq for the behaviour that's common to all sequence classes, bestie β this page is just the special stuff π
$seq = Math::NumSeq::DigitProductSteps->new ()$seq = Math::NumSeq::DigitProductSteps->new (values_type => $str, radix => $integer)
create and return a brand new sequence object. new object, new era, periodt β¨
π Random Access π
$value = $seq->ith($i)β return the sequence value, either thecountor the finalrootvalue, whichever you selected. your pick, your power π$bool = $seq->pred($value)β return true if$valueoccurs in the sequence. for the count of steps this means any integer"$value >= 0", or for a root, any digit"0 <= $value < radix". simple as that π«Ά
π SEE ALSO π
Math::NumSeqMath::NumSeq::DigitProduct
go read those too, i'm obsessed with a well-organized module family π
π 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/>.
bestie that warranty disclaimer is doing the MOST and honestly? respect. no cap, read your licenses π
and that's the whole page!! this was Math::N...uctSteps(3) from perl v5.42.0, dated 2025-07-25 β mwah, ty for reading, go multiply some digits, ily π«Άπβ¨
π¦ 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