search.cpan.org is shutting down
Kevin Ryde > Math-NumSeq > Math::NumSeq::PythagoreanHypots

Math-NumSeq-72.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

 Open 0
View/Report Bugs
Module Version: 72

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

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

FUNCTIONS

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::PlanePath::PythagoreanTree

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