pythag3

Pythagorean triples

Pythagorean triples are three integers a, b, c where + = . Such a triple is primitive when a, b, c > 0 and gcd(a, b, c) = 1. Geometrically, a, b, c represent the sides of a right triangle.

class boring_math.pythagorean_triples.pythag3.Pythag3

Pythagorean triple generation

Class to generate tuples of Pythagorean triples.

__init__(last_square: int = 500, /)
triples(a_start: int = 3, a_max: int = 3, abc_max: int | None = None) Iterator[tuple[int, int, int]]

Generate Pythagorean triples

param a_start:

Starting value for the smallest side a.

param a_max:

Maximum value for the smallest side a.

param abc_max:

Maximum value for any side.

yields:

Tuples (a, b, c) with a_start <= a <= a_max and 3 <= a < b < c <= abc_max.

Note

Returned Iterator iterates the triples in dictionary order.

If abc_max not given, returns all theoretically possible triples with a_start <= a <= a_max.

Never returns an infinite iterator.