1Math::NumSeq::HappyNumbUesresr(3C)ontributed Perl DocumeMnattaht:i:oNnumSeq::HappyNumbers(3)
2
3
4

NAME

6       Math::NumSeq::HappyNumbers -- reaching 1 under repeated sum of squares
7       of digits
8

SYNOPSIS

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

DESCRIPTION

15       This sequence is the happy numbers which are the numbers eventually
16       reaching 1 on repeatedly taking the sum of the squares of the digits.
17
18           1, 7, 10, 13, 19, 23, ...
19           starting i=1
20
21       For example 23 is a happy number because the sum of squares of its
22       digits (ie. 2 and 3) is 2*2+3*3=13, then the same sum of squares again
23       1*1+3*3=10, then 1*1+0*0=1 reaches 1.
24
25       In decimal it can be shown that for a non-zero starting point this
26       procedure always reaches either 1 or the cycle 4,16,37,58,89,145,42,20.
27       The values which reach 1 are called happy numbers.
28
29       An optional "radix" parameter can select a base other than decimal.
30       Base 2 and base 4 are not very interesting since for them every number
31       except 0 is happy.
32

FUNCTIONS

34       See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
35       classes.
36
37       "$seq = Math::NumSeq::HappyNumbers->new ()"
38       "$seq = Math::NumSeq::HappyNumbers->new (radix => $r)"
39           Create and return a new sequence object.
40
41       "$bool = $seq->pred($value)"
42           Return true if $value is a happy number, meaning repeated sum of
43           squares of its digits reaches 1.
44

SEE ALSO

46       Math::NumSeq, Math::NumSeq::HappySteps, Math::NumSeq::DigitSum
47

HOME PAGE

49       <http://user42.tuxfamily.org/math-numseq/index.html>
50

LICENSE

52       Copyright 2011, 2012, 2013, 2014, 2016, 2019 Kevin Ryde
53
54       Math-NumSeq is free software; you can redistribute it and/or modify it
55       under the terms of the GNU General Public License as published by the
56       Free Software Foundation; either version 3, or (at your option) any
57       later version.
58
59       Math-NumSeq is distributed in the hope that it will be useful, but
60       WITHOUT ANY WARRANTY; without even the implied warranty of
61       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
62       General Public License for more details.
63
64       You should have received a copy of the GNU General Public License along
65       with Math-NumSeq.  If not, see <http://www.gnu.org/licenses/>.
66
67
68
69perl v5.32.1                      2021-01-27     Math::NumSeq::HappyNumbers(3)
Impressum