1Math::NumSeq::HappyStepUss(e3r)Contributed Perl DocumentMaattiho:n:NumSeq::HappySteps(3)
2
3
4

NAME

6       Math::NumSeq::HappySteps -- number of sum of squares of digits
7       iterations to reach a repeat
8

SYNOPSIS

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

DESCRIPTION

15       This is the number of iterations of the "HappyNumbers" style "sum of
16       squares of digits" is required to reach a repeat of a value seen
17       before, and therefore to establish whether a number is a happy number
18       or not.
19
20           1, 9, 13, 8, 12, 17, 6, 13, 12, 2,
21           starting i=1
22
23       For example i=10 is value 2 because 10->1->1 is 2 iterations to get to
24       a repeat (a repeat of 1).  At i=1 itself the value is 1 since 1
25       iteration reaches 1 again which is itself the repeat.  That count 1 at
26       i=1 is the minimum.
27
28   Radix
29       An optional "radix" parameter selects a base other than decimal.  In
30       binary "radix=>2" the digits are all either 0 or 1 so "sum of squares
31       of digits" is the same as a plain "sum of digits".
32
33       In some bases there's longer cycles than others which a non-happy
34       number might fall into.  For example base 20 has a cycle
35
36           10 -> 100 -> 25 -> 26 -> ... -> 61 -> 10
37           total 26 elements
38
39       When a non-happy falls into such a cycle its "HappySteps" count here is
40       at least 26 (or whatever amount) to reach a repeat.
41

FUNCTIONS

43       See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
44       classes.
45
46       "$seq = Math::NumSeq::HappySteps->new ()"
47       "$seq = Math::NumSeq::HappySteps->new (radix => $r)"
48           Create and return a new sequence object.
49
50   Random Access
51       "$value = $seq->ith($i)"
52           Return the number of iterations starting from $i required to reach
53           a repeat.
54

SEE ALSO

56       Math::NumSeq, Math::NumSeq::HappyNumbers, Math::NumSeq::DigitSum
57

HOME PAGE

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

LICENSE

62       Copyright 2011, 2012, 2013, 2014, 2016 Kevin Ryde
63
64       Math-NumSeq is free software; you can redistribute it and/or modify it
65       under the terms of the GNU General Public License as published by the
66       Free Software Foundation; either version 3, or (at your option) any
67       later version.
68
69       Math-NumSeq is distributed in the hope that it will be useful, but
70       WITHOUT ANY WARRANTY; without even the implied warranty of
71       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
72       General Public License for more details.
73
74       You should have received a copy of the GNU General Public License along
75       with Math-NumSeq.  If not, see <http://www.gnu.org/licenses/>.
76
77
78
79perl v5.30.0                      2019-08-05       Math::NumSeq::HappySteps(3)
Impressum