Share your repls and programming experiences

← Back to all posts
Primitive Pythagorean triples
ExcelInfinity (0)

Finds primitive Pythagorean triples. Pythagorean triples are (a, b, c) triples such that a squared + b squared = c squared. Primitive pythagorean triples are triples such that gcd(a, b, c) = 1. This uses a parametrization technique: (a, b, c) is (n^2 - m^2, 2mn, n^2 + m^2) when one of m and n is even and one is odd, as well as n > m.