The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::NumSeq::DigitProductSteps -- product of digits, multiplicative persistence and root

SYNOPSIS

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

DESCRIPTION

In progress ...

This is an iteration of taking the product of digits repeated until reaching a single digit value. The default is the count of steps, which is also called the multiplicative persistence.

    starting i=0
    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,...

For example i=39 goes 3*9=27, 2*7=14, 1*4=4 to reach a single digit, so value=3 iterations.

The values_type => 'root' gives the final digit reached by the steps, which is also called the multiplicative 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,...

i=0 through i=9 are already single digits so their count is 0 and root is it itself. Then i=10 to i=19 all take just a single iteration to reach a single digit. i=25 is the first to require 2 iterations.

Any i with a 0 digit takes just one iteration and finishes with root 0. Any any i like 119111 which is all 1s except for at most one non-1 takes just one iteration.

Radix

An optional radix parameter selects a base other than decimal.

Binary radix=>2 is not very interesting since the digit product is always either 0 or 1 so for i>=2 always just 1 iteration and root 0 except i=2^k-1 all 1s with root 1.

FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

$seq = Math::NumSeq::DigitProductSteps->new ()
$seq = Math::NumSeq::DigitProductSteps->new (values_type => $str, radix => $integer)

Create and return a new sequence object.

$bool = $seq->ith($value)

Return the iteration result, either count or final root value as selected.

SEE ALSO

Math::NumSeq, Math::NumSeq::DigitProduct

HOME PAGE

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

LICENSE

Copyright 2012 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/>.