terican

Last verified · v1.0

Calculator · math

Pythagorean Triples Calculator (Euclid's Formula)

Generate primitive and non-primitive Pythagorean triples using Euclid's formula a=k(m²−n²), b=2kmn, c=k(m²+n²). Enter m, n, and optional k for instant results.

FreeInstantNo signupOpen source

Inputs

Selected Triple Value

Explain my result

0/3 free

Get a plain-English breakdown of your result with practical next steps.

Selected Triple Value

The formula

How the
result is
computed.

What Are Pythagorean Triples?

A Pythagorean triple is a set of three positive integers (a, b, c) satisfying a² + b² = c² — the exact-integer form of the Pythagorean theorem for right triangles. The most familiar example, (3, 4, 5), was used in ancient Egyptian rope surveying and appears on Babylonian clay tablet Plimpton 322, dated to roughly 1800 BCE. Beyond history, these triples arise in architecture, computer graphics, and competitive mathematics. Euclid provided a complete parametric formula to generate every such triple, and this calculator implements it directly.

Euclid’s Formula: How It Works

Given two positive integers m and n with m > n > 0, and a positive integer multiplier k, Euclid’s formula defines a Pythagorean triple as:

  • a = k(m² − n²) — one leg of the right triangle
  • b = 2kmn — the second leg
  • c = k(m² + n²) — the hypotenuse

Setting k = 1 yields the base triple for the chosen (m, n) pair. As Keith Conrad demonstrates in his analysis of Pythagorean descent, this parametrization is complete: every integer solution to a² + b² = c² appears when m, n, and k range over all valid values (Conrad, Pythagorean Descent, University of Connecticut).

Algebraic Proof of Correctness

The identity holds by expanding a² + b²: k²(m² − n²)² + (2kmn)² = k²[(m² − n²)² + 4m²n²] = k²(m² + n²)² = c². The step (m² − n²)² + 4m²n² = (m² + n²)² is a standard polynomial identity. This guarantees every output triple satisfies the theorem exactly, with zero floating-point error.

Primitive vs. Non-Primitive Triples

A Pythagorean triple is called primitive when gcd(a, b, c) = 1 — the three values share no common factor. To generate a primitive triple, three conditions must hold: k = 1; gcd(m, n) = 1 (m and n coprime); and m and n must have opposite parity (one even, one odd). When k > 1, every element is divisible by k, producing a non-primitive triple. For example, k = 2, m = 2, n = 1 gives (6, 8, 10) = 2 × (3, 4, 5). D. Joyce at Clark University confirms that every Pythagorean triple is either primitive or an integer multiple of a primitive triple (Joyce, Right Triangles, Clark University).

Worked Examples

Example 1: The (3, 4, 5) Triple

Set m = 2, n = 1, k = 1. Then a = 1 × (4 − 1) = 3, b = 2 × 1 × 2 × 1 = 4, c = 1 × (4 + 1) = 5. Check: 9 + 16 = 25. Since gcd(2, 1) = 1 and 2 is even while 1 is odd, this is a primitive triple.

Example 2: The (5, 12, 13) Triple

Set m = 3, n = 2, k = 1. Then a = 9 − 4 = 5, b = 2 × 3 × 2 = 12, c = 9 + 4 = 13. Check: 25 + 144 = 169. Primitive, since gcd(3, 2) = 1 and opposite parity holds.

Example 3: The (8, 15, 17) Triple

Set m = 4, n = 1, k = 1. Then a = 16 − 1 = 15, b = 2 × 4 × 1 = 8, c = 16 + 1 = 17. Check: 64 + 225 = 289 = 17². Primitive.

Example 4: A Non-Primitive Triple

Set m = 2, n = 1, k = 5. Then a = 5 × 3 = 15, b = 5 × 4 = 20, c = 5 × 5 = 25, giving (15, 20, 25) = 5 × (3, 4, 5). Check: 225 + 400 = 625. Non-primitive because k = 5.

Real-World Applications

Pythagorean triples have concrete uses well beyond the classroom:

  • Construction: The 3-4-5 ratio is the fastest field method for verifying 90° corners — mark 3 units on one wall and 4 on the adjacent wall; a diagonal of exactly 5 confirms a right angle.
  • Surveying: Large triples such as (20, 21, 29) and (28, 45, 53) let surveyors lay out right angles over long distances with integer measurements and no trigonometry tables.
  • Computer graphics: Integer-coordinate right triangles eliminate floating-point drift in rasterized line segments and texture mapping pipelines.
  • Competitive mathematics: Memorizing triples like (7, 24, 25), (9, 40, 41), and (11, 60, 61) allows instant identification of right triangles in olympiad geometry problems.

For a rigorous proof of completeness, J. Silverman’s Number Theory Unit 4 at Brown University provides an accessible yet formal treatment of why Euclid’s parametrization covers every possible case (Silverman, Number Theory Unit 4, Brown University).

Reference

Frequently asked questions

What is a Pythagorean triple?
A Pythagorean triple is a set of three positive integers (a, b, c) satisfying a² + b² = c², making them exact integer side lengths of a right triangle. The simplest example is (3, 4, 5): 9 + 16 = 25. These triples appear throughout geometry, construction, number theory, and competitive mathematics, and infinitely many of them exist.
How does Euclid's formula generate Pythagorean triples?
Euclid's formula takes two positive integers m > n > 0 and a multiplier k, then computes a = k(m²−n²), b = 2kmn, and c = k(m²+n²). For m=3, n=2, k=1, the result is (5, 12, 13): 25+144=169. The formula is mathematically proven to generate every Pythagorean triple without exception, making it the definitive parametric solution.
What is a primitive Pythagorean triple and how is one generated?
A primitive Pythagorean triple has gcd(a, b, c) = 1, meaning the three numbers share no common factor greater than 1. To generate one with Euclid's formula, set k=1 and choose m and n to be coprime (gcd(m,n)=1) with opposite parity (one even, one odd). Examples include (3,4,5), (5,12,13), (8,15,17), and (7,24,25). Every non-primitive triple is simply an integer multiple of a primitive one.
What values of m and n produce the 5-12-13 Pythagorean triple?
Setting m=3, n=2, and k=1 produces the (5, 12, 13) triple. The computation: a = 1×(9−4) = 5, b = 2×1×3×2 = 12, c = 1×(9+4) = 13. Verification: 25 + 144 = 169 = 13². Since gcd(3,2)=1 and 3 is odd while 2 is even (opposite parity), this is confirmed as a primitive Pythagorean triple.
Can Euclid's formula generate all Pythagorean triples, or only some?
Euclid's formula generates every Pythagorean triple without exception. With k ranging over all positive integers and (m, n) ranging over all coprime pairs of opposite parity with m > n > 0, the formula covers the complete set exactly once per primitive triple (and all its multiples). Mathematicians Keith Conrad at the University of Connecticut and Joseph Silverman at Brown University both provide published proofs of this completeness result.
What are the most important real-world applications of Pythagorean triples?
Pythagorean triples have several practical applications. In construction and carpentry, the 3-4-5 method verifies right angles without a protractor: measure 3 units and 4 units on adjacent walls and confirm a 5-unit diagonal. In surveying, larger triples like (20, 21, 29) establish right angles across long distances. In computer graphics, integer triples eliminate floating-point rounding errors. In math competitions, recognizing triples such as (7, 24, 25) and (9, 40, 41) instantly identifies right triangles.