Pythagorean Triples Generator
Generates all Pythagorean triples (a, b, c) satisfying a² + b² = c² up to a chosen limit, classifying each as primitive or non-primitive. Useful for geometry problems, number theory study, and competition math.
About this calculator
A Pythagorean triple is a set of three positive integers (a, b, c) satisfying a² + b² = c². A triple is primitive when gcd(a, b, c) = 1 — no common factor reduces it further. Every primitive triple can be generated by Euclid's formula: a = m² − n², b = 2mn, c = m² + n², where m > n > 0, gcd(m, n) = 1, and m − n is odd. Non-primitive triples are integer multiples of primitive ones: (ka, kb, kc) for k ≥ 2. The calculator iterates over valid (m, n) pairs up to your chosen maximum hypotenuse, collects all qualifying triples, and optionally sorts them by hypotenuse length or perimeter.
How to use
Set Maximum Value to 20 and Triple Type to 'all'. For m = 2, n = 1: a = 4 − 1 = 3, b = 2·2·1 = 4, c = 4 + 1 = 5 — the classic (3, 4, 5) primitive triple. Multiples give (6, 8, 10) and (9, 12, 15), both ≤ 20 hypotenuse. For m = 3, n = 2: a = 9 − 4 = 5, b = 12, c = 13 — another primitive triple with c = 13 ≤ 20. Sorting by c, the results appear: (3,4,5), (6,8,10), (5,12,13), (9,12,15), (8,15,17). Verify any row: 5² + 12² = 25 + 144 = 169 = 13². ✓
Frequently asked questions
What is the difference between a primitive and a non-primitive Pythagorean triple?
A primitive Pythagorean triple has gcd(a, b, c) = 1, meaning the three numbers share no common factor. Examples include (3, 4, 5) and (5, 12, 13). A non-primitive triple is simply a primitive triple scaled by an integer k ≥ 2, such as (6, 8, 10) = 2·(3, 4, 5). Every non-primitive triple can be reduced to a unique primitive triple by dividing through by the GCD. Primitive triples are the fundamental building blocks from which all Pythagorean triples are constructed.
How does Euclid's formula generate all primitive Pythagorean triples?
Euclid's formula states that for integers m > n > 0 with gcd(m, n) = 1 and m − n odd, the values a = m² − n², b = 2mn, c = m² + n² form a primitive Pythagorean triple. You can verify it algebraically: a² + b² = (m²−n²)² + (2mn)² = m⁴ − 2m²n² + n⁴ + 4m²n² = (m²+n²)² = c². Crucially, every primitive triple arises from exactly one such (m, n) pair, so the formula is exhaustive. The coprimality and parity conditions ensure primitivity and avoid duplicates.
Why are there infinitely many Pythagorean triples but finitely many below a given limit?
Because the formula a = m²−n², b = 2mn, c = m²+n² generates a new triple for every valid integer pair (m, n), and there are infinitely many such pairs, the full collection of Pythagorean triples is infinite. However, for any fixed maximum value L, only finitely many pairs satisfy c = m²+n² ≤ L, so the list below any bound is always finite and completely enumerable. This is why the calculator needs a maximum-value cutoff — without one, it would run forever. Setting L = 100, for example, yields 16 primitive triples.