pythag3¶
Pythagorean triples
Pythagorean triples are three integers a, b, c where a² + b² = c².
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(last_square: int = 500, /)¶
Pythagorean triple iteration class.
- extend_squares(last_to_square: int, /) None¶
Extend the self.squares perfect square lookup table.
- triples(a_start: int = 3, a_max: int = 3, abc_max: int | None = None) Iterator[tuple[int, int, int]]¶
Returns an iterator of all possible primitive Pythagorean triples.
Note
Returned Iterator iterates in tuples
(a, b, c)in dictionary order.If
abc_maxnot given, returns all theoretically possible triples witha_start <= a <= a_max.Never returns an infinite iterator.
- Parameters:
a_start – Starting value for the smallest side a.
a_max – Maximum value for the smallest side a.
abc_max – Maximum value for any side.
- Returns:
Iterator of Tuples
(a, b, c)witha_start <= a <= a_maxand3 <= a < b < c <= abc_max