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¶
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)witha_start <= a <= a_maxand3 <= a < b < c <= abc_max.
Note
Returned Iterator iterates the triples in dictionary order.
If
abc_maxnot given, returns all theoretically possible triples witha_start <= a <= a_max.Never returns an infinite iterator.