++ed by:

2 PAUSE user(s)

Kevin Ryde


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


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


This is integers occurring as the hypotenuse of a Pythagorean triple, ie. the C in A^2+B^2=C^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

Option pythagorean_type => "primitive" restricts to those hypotenuses occurring in primitive triples. For any triple A,B,C a multiple k*A,k*B,k*C is also a triple. The primitive triples are those where A,B have no common factor which could be divided out.

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

It can be shown these are integers comprised only of prime factors 4k+1. (For all triples at least one 4k+1 prime factor, and for primitive triples all 4k+1 prime factors.)


See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence 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 (to look for either one or all 4k+1). 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.


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





Copyright 2010, 2011, 2012, 2013, 2014 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/>.