++ed by:
Kevin Ryde
and 1 contributors

# NAME

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

# SYNOPSIS

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

# DESCRIPTION

This sequence is the happy numbers 1,7,10,13,19,23,etc, which are the numbers eventually reaching 1 on repeatedly taking the sum of the squares of the digits.

For example 23 is a happy number because the sum of squares of its digits (2 and 3) is 2*2+3*3=13, then the same sum of squares again 1*1+3*3=10, then 1*1+0*0=1 reaches 1.

In decimal it can be shown that for a non-zero starting point this procedure always reaches either 1 or a cycle 4,16,37,58,89,145,42,20. The values which reach 1 are called happy numbers.

An optional `radix` parameter can select a base other than decimal. Base 2 and base 4 are not very interesting since for them every number except 0 is happy.

# FUNCTIONS

`\$seq = Math::NumSeq::HappyNumbers->new (key=>value,...)`

Create and return a new sequence object.

`\$bool = \$seq->pred(\$value)`

Return true if `\$value` is a happy number, meaning repeated sum of squares of digits reaches 1.