Math::NumSeq::TotientStepsSum -- sum of repeated totients to reach 1


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


The sum of the totients on repeatedly applying the totient function to reach 1.

    1, 3, 6, 7, 12, 9, 16, 15, 18, 17, 28, 19, 32, ...

For example i=5 applying the totient function goes 5 -> 4 -> 2 -> 1 so total value=5+4+2+1=12.

The default is to include the initial i itself in the sum. Option including_self => 0 excludes, in which case for example i=5 has value=4+2+1=7.

    0, 1, 3, 3, 7, 3, 9, 7, 9, 7, 17, 7, 19, ...

See Math::NumSeq::TotientPerfect for totient sums equal to i itself.


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

$seq = Math::NumSeq::TotientStepsSum->new ()

Create and return a new sequence object.

Random Access

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

Return the totient steps sum running i down to 1.


Math::NumSeq, Math::NumSeq::Totient, Math::NumSeq::TotientSteps, Math::NumSeq::TotientPerfect



Copyright 2011, 2012, 2013 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 <>.