Pythagorean Triples Calculator — Euclid's Formula
Find integer-sided right triangles (Pythagorean triples) from Euclid's formula. Enter m > n ≥ 1 to produce a = m²−n², b = 2mn, c = m²+n², with a diagram confirming a² + b² = c².
Longest side — satisfies a² + b² = c²
- 1
m²
2² = 4 - 2
n²
1² = 1 - 3
Leg a = m² − n²
4 − 1 = 3 - 4
Leg b = 2mn
2 × 2 × 1 = 4 - 5
Hypotenuse c = m² + n²
4 + 1 = 5By construction, a² + b² = c² — this is always a valid Pythagorean triple.
How does this calculator work?
Euclid's formula produces every Pythagorean triple: a = m²−n², b = 2mn, c = m²+n² for integers m > n ≥ 1. Verify: (m²−n²)² + (2mn)² = (m²+n²)². The triple is primitive (gcd=1) when gcd(m,n)=1 and m−n is odd. Smallest: m=2, n=1 → (3, 4, 5).
Formula
How this is calculated
Euclid's formula is the classical way to generate every Pythagorean triple. Given two positive integers m > n, the three values a = m²−n², b = 2mn, c = m²+n² always satisfy a² + b² = c². The proof: (m²−n²)² + (2mn)² = m⁴ − 2m²n² + n⁴ + 4m²n² = m⁴ + 2m²n² + n⁴ = (m²+n²)² = c².
A triple is called primitive when gcd(a, b, c) = 1 — the three integers share no common factor. The formula produces a primitive triple precisely when gcd(m, n) = 1 and m − n is odd (one parameter even, the other odd). The smallest primitive triple (3, 4, 5) comes from m = 2, n = 1. Non-primitive triples arise when gcd(m, n) > 1; for example m = 4, n = 2 gives (12, 16, 20) = 4×(3, 4, 5).
Common examples: (3, 4, 5) from m=2 n=1; (5, 12, 13) from m=3 n=2; (8, 15, 17) from m=4 n=1; (7, 24, 25) from m=4 n=3. Every primitive Pythagorean triple is generated by some m, n satisfying the conditions above — Euclid's formula is both sufficient and necessary for primitives.
Frequently asked questions
A primitive triple (a, b, c) has gcd(a, b, c) = 1 — the three integers share no common factor. Every non-primitive triple is an integer multiple of a primitive one. Euclid's formula produces a primitive triple when gcd(m, n) = 1 and m − n is odd (i.e. exactly one of m, n is even).
Yes — every primitive triple is generated by a unique pair m > n > 0 with gcd(m, n) = 1 and m − n odd. All non-primitive triples are integer multiples of primitive ones, so the formula (combined with scaling) covers every Pythagorean triple. The proof uses unique factorisation in the Gaussian integers.
Systematically try m values from 2 upward, compute n = m − 1, m − 2, … (with n ≥ 1) and check if a = m²−n² or b = 2mn matches your leg. Alternatively, if you know the hypotenuse c, find m and n such that m²+n² = c.
Also known as
TG we-Calculate Editorial Team. (2026). Pythagorean Triples Calculator — Euclid's Formula [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/pythagorean-triples-calculator
TG we-Calculate Editorial Team. "Pythagorean Triples Calculator — Euclid's Formula." TG we-Calculate. 2026. https://we-calculate.com/calculator/pythagorean-triples-calculator.
TG we-Calculate Editorial Team, "Pythagorean Triples Calculator — Euclid's Formula," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/pythagorean-triples-calculator
@misc{wecalculate_pythagorean_triples_calculator, title = {Pythagorean Triples Calculator — Euclid's Formula}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/pythagorean-triples-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
