NAME
App::MathImage::NumSeq::HappyNumbers -- happy numbers
SYNOPSIS
use App::MathImage::NumSeq::Squares;
my $seq = App::MathImage::NumSeq::Squares->new;
my ($i, $value) = $seq->next;
DESCRIPTION
This sequence is the happy numbers, those where repeatedly taking the sum of the squares of the digits eventually gives 1.
For example 23 is a happy number because 2*2+3*3=13, then 1*1+3*3=10, then 1*1+0*0=1.
In decimal it can be shown that this procedure always reaches one of the ten values 0, 1, 4, 16, 20, 37, 42, 58, 89, 145. Values which reach 1 are called happy numbers.
An optional radix
parameter can select a base other than decimal. Base 2 (binary) and base 4 are not very interesting since for them every number is happy (except 0).
FUNCTIONS
$seq = App::MathImage::NumSeq::Squares->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 its digits reaches 1.
SEE ALSO
HOME PAGE
http://user42.tuxfamily.org/math-image/index.html
LICENSE
Copyright 2010, 2011 Kevin Ryde
Math-Image 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-Image 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-Image. If not, see <http://www.gnu.org/licenses/>.