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, which means those for which repeatedly taking the sum of the squares of its digits eventually gives 1.

For example 23 is a happy number because 2^2+3^2=13, then 1^2+3^2=10, then 1^2+0^2=1.

In decimal it can be shown that this sum of squares of digits procedure always reaches one of the ten values 0, 1, 4, 16, 20, 37, 42, 58, 89, 145. Those which reach 1 are called happy numbers.

An optional radix parameter can select a base other than decimal for the procedure. Base 2 (binary) and base 4 are not very interesting since for them every number is happy.

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

App::MathImage::NumSeq

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/>.