1Math::NumSeq::DigitProdUuscetrStCeopnst(r3i)buted Perl DMoactuhm:e:nNtuamtSieoqn::DigitProductSteps(3)
2
3
4
6 Math::NumSeq::DigitProductSteps -- multiplicative persistence and
7 digital root
8
10 use Math::NumSeq::DigitProductSteps;
11 my $seq = Math::NumSeq::DigitProductSteps->new (values_type => 'count');
12 my ($i, $value) = $seq->next;
13
15 This is an iteration taking the product of the digits of a number until
16 reaching a single digit value. The sequence values are the count of
17 steps, also called the multiplicative persistence.
18
19 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,...
20 starting i=0
21
22 For example i=39 goes 3*9=27 -> 2*7=14 -> 1*4=4 to reach a single
23 digit, so value=3 iterations.
24
25 The "values_type => 'root'" gives the final digit reached by the steps,
26 which is called the multiplicative digital root.
27
28 values_type => 'root'
29 0,1,2,...,9,0,1,...,9,0,2,4,6,8,0,2,4,6,8,0,3,6,9,2,5,8,...
30
31 i=0 through i=9 are already single digits so their count is 0 and root
32 is the value itself. Then i=10 to i=19 all take just a single
33 iteration to reach a single digit. i=25 is the first to require 2
34 iterations.
35
36 Any i with a 0 digit takes just one iteration to get to root 0. Any i
37 like 119111 which is all 1s except for at most a single non-1 takes
38 just one iteration. This includes the repunits 111..11.
39
40 Radix
41 An optional "radix" parameter selects a base other than decimal.
42
43 Binary "radix=>2" is not very interesting since the digit product is
44 always either 0 or 1. i>=2 always takes just 1 iteration and has root
45 0 except for i=2^k-1 all 1s with root 1.
46
48 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
49 classes.
50
51 "$seq = Math::NumSeq::DigitProductSteps->new ()"
52 "$seq = Math::NumSeq::DigitProductSteps->new (values_type => $str,
53 radix => $integer)"
54 Create and return a new sequence object.
55
56 Random Access
57 "$value = $seq->ith($i)"
58 Return the sequence value, either count or final root value as
59 selected.
60
61 "$bool = $seq->pred($value)"
62 Return true if $value occurs in the sequence. For the count of
63 steps this means any integer "$value >= 0", or for a root any digit
64 "0 <= $value < radix".
65
67 Math::NumSeq, Math::NumSeq::DigitProduct
68
70 <http://user42.tuxfamily.org/math-numseq/index.html>
71
73 Copyright 2012, 2013, 2014 Kevin Ryde
74
75 Math-NumSeq is free software; you can redistribute it and/or modify it
76 under the terms of the GNU General Public License as published by the
77 Free Software Foundation; either version 3, or (at your option) any
78 later version.
79
80 Math-NumSeq is distributed in the hope that it will be useful, but
81 WITHOUT ANY WARRANTY; without even the implied warranty of
82 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
83 General Public License for more details.
84
85 You should have received a copy of the GNU General Public License along
86 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
87
88
89
90perl v5.28.0 2014-06-29Math::NumSeq::DigitProductSteps(3)