The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::NumSeq::PythagoreanHypots -- hypotenuses of Pythagorean triples

SYNOPSIS

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

DESCRIPTION

The sequence of integers occurring as the hypotenuse of a Pythagorean triple, ie. the z in x^2+y^2=z^2.

    5, 10, 13, 15, 17, 20, ...

For example 13 is in the sequence because it occurs as 1^2+12^2 = 13^2.

It can be shown that this is all integers which have at least one prime factor of the form 4k+1.

Primitive Triples

For any triple x,y,z a multiple k*x,k*y,k*z is also a triple. The primitive triples are those where x,y have no common factor. Option pythagorean_type => "primitive" restricts to those hypots occuring in primitive triples

    5, 13, 17, 25, 29, 37, ...

It can be shown these are integers comprised only of prime factors 4k+1.

FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for the behaviour common to all path classes.

$seq = Math::NumSeq::PythagoreanHypots->new ()
$seq = Math::NumSeq::PythagoreanHypots->new (pythagorean_type => $str)

Create and return a new sequence object.

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

Return true if $value occurs as a hypotenuse in a Pythagorean triple.

This calculation requires checking the prime factors of $value. In the current code a hard limit of 2**32 is placed on $value in the interests of not going into a near-infinite loop.

SEE ALSO

Math::NumSeq, Math::NumSeq::Cubes

Math::PlanePath::PythagoreanTree

HOME PAGE

http://user42.tuxfamily.org/math-numseq/index.html

LICENSE

Copyright 2010, 2011, 2012 Kevin Ryde

Math-NumSeq 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-NumSeq 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-NumSeq. If not, see <http://www.gnu.org/licenses/>.