Primitive Pythagorean Triples

A primitive Pythagorean triple is one whose three numbers share no common factor. Here is how to test for it, why one leg is always even, a complete proof that Euclid's formula produces every primitive triple, and the divisibility facts they all obey.

By the PythagoreanTheorem.net teamUpdated 12 min read

A primitive Pythagorean triple is a Pythagorean triple (a, b, c) whose three numbers have no common factor greater than 1, so gcd(a, b, c) = 1. Examples are 3-4-5, 5-12-13 and 8-15-17. Every other triple, such as 6-8-10, is a whole-number multiple of exactly one primitive triple.

Primitive triples are the atoms of the subject: understand them and you understand every triple. The proofs below need only remainders, factoring and prime numbers.

Definition and examples

Here gcd means the greatest common divisor, the largest whole number that divides all the numbers in question. A triple is primitive when that number is 1; in other words, you cannot shrink the triangle and keep whole-number sides.

If a triple is not primitive, let g = gcd(a, b, c) and divide through. The result is still a triple, because dividing a2 + b2 = c2 by g2 gives (a over g)2 + (b over g)2 = (c over g)2, and it is primitive, because we removed the largest common factor. So 30-40-50 = 10 × (3-4-5) and 20-48-52 = 4 × (5-12-13).

010203001020304050 3-4-5 5-12-13 8-15-17 7-24-25 20-21-29 12-35-37 9-40-41 shorter leg alonger leg b
All 20 triples with c ≤ 50 as points (a, b). Multiples of a triple lie on the same line through the origin, evenly spaced: the ten dots on the 3-4-5 line are 3-4-5, 6-8-10, …, 30-40-50. The primitive triple (solid dot) is always the first dot on its line.

A useful lemma: checking two numbers is enough

In a Pythagorean triple, any prime that divides two of the numbers also divides the third. Suppose a prime p divides a and c. Then it divides c2 − a2 = b2, and a prime that divides b2 must divide b. The other pairs work the same way. So for a triple,

gcd(a, b, c) = 1 ⇔ gcd(a, b) = 1 ⇔ gcd(a, c) = 1 ⇔ gcd(b, c) = 1

That means the numbers of a primitive triple are pairwise coprime: no two of them share a factor.

How to test whether a triple is primitive

  1. Confirm it is a triple: check a2 + b2 = c2.
  2. Find gcd(a, b), the greatest common divisor of the two legs. For small numbers, list the factors; for larger ones, use the Euclidean algorithm (divide, keep the remainder, repeat).
  3. Read the answer. If the gcd is 1, the triple is primitive. If it is g > 1, divide all three numbers by g to get the primitive triple underneath.

Example: is 20-99-101 primitive?

It is a triple, since 400 + 9801 = 10201 = 1012. Now run the Euclidean algorithm on the legs:

99= 4 × 20 + 1920= 1 × 19 + 119= 19 × 1 + 0

The last nonzero remainder is 1, so gcd(20, 99) = 1 and 20-99-101 is primitive.

Triplegcd(a, b)Primitive?Reduces to
20-99-1011yes—
33-44-5511no11 × (3, 4, 5)
39-80-891yes—
24-70-742no2 × (12, 35, 37)
28-45-531yes—
45-108-1179no9 × (5, 12, 13)

ShortcutsA triple is certainly not primitive if both legs are even, if the hypotenuse is even, or if the hypotenuse is a multiple of 3 (all proved below). For example, 117 = 9 × 13, so 45-108-117 cannot be primitive, and indeed it is 9 × (5-12-13).

Exactly one leg is even, and the hypotenuse is odd

The key tool is what happens to squares when you divide by 4. An even number is 2k and an odd number is 2k + 1, so

(2k)2= 4k2 (remainder 0)(2k + 1)2= 4k2 + 4k + 1 (remainder 1)

Every perfect square leaves remainder 0 or 1 when divided by 4, never 2 or 3. Now take a primitive triple and look at the legs:

  • Both even is impossible. Then c2 = a2 + b2 is even, so c is even, and 2 divides all three numbers.
  • Both odd is impossible. Then a2 + b2 leaves remainder 1 + 1 = 2, and no square does.
  • So one leg is odd and the other even, and c2 = odd + even is odd, which makes c odd.
b oddb evena odda even ✗ impossibleodd² + odd² leavesremainder 2 when ÷ 4 ✓ works3² + 4² = 25 = 5²c is odd ✓ works8² + 15² = 289 = 17²c is odd ✗ not primitivethen c is even too, so2 divides a, b and c
The four ways to choose the parities of the legs. Only "one odd, one even" can happen in a primitive triple.

From here on we follow the usual convention: a is the odd leg and b the even leg, even if a is the longer one. In 8-15-17, for instance, a = 15 and b = 8.

Every primitive triple comes from Euclid's formula

TheoremLet (a, b, c) be a primitive Pythagorean triple with b even. Then there are unique whole numbers m > n > 0, with no common factor and not both odd, such that a = m2 − n2, b = 2mn and c = m2 + n2. Conversely, every such pair m, n gives a primitive triple.

This is the precise sense in which Euclid's formula "generates all primitive triples". The proof uses nothing beyond factoring and the fact that every whole number splits into primes in only one way.

Proof that every primitive triple has this form

  1. Factor. Rearranging gives b2 = c2 − a2 = (c − a)(c + a). Since a and c are both odd, c − a and c + a are both even. Write u = c + a over 2 and v = c − a over 2, which are positive whole numbers with u > v. Dividing by 4 gives (b over 2)2 = uv, where b over 2 is a whole number because b is even. Notice also that c = u + v and a = u − v.
  2. The factors are coprime. Any number d dividing both u and v divides u + v = c and u − v = a. But gcd(a, c) = 1 by the lemma, so d = 1.
  3. Each factor is a square. In the prime factorization of the square uv, every prime appears an even number of times. Because u and v share no prime, each prime of u appears in u alone, still an even number of times, so u is a perfect square; likewise v. Write u = m2 and v = n2 with m > n > 0.
  4. Read off the formula. Now c = u + v = m2 + n2, a = u − v = m2 − n2, and b over 2 = √uv = mn, so b = 2mn.
  5. Check the conditions. A common factor of m and n would be a common factor of u and v, so gcd(m, n) = 1. And m, n can't both be odd (or both even), since then a = m2 − n2 would be even. This completes the proof.
a² = 9 c = 5c = 5 c + a = 8c − a = 2 c² − a² = 16 squares c² − a² = 25 − 9 = 16(c − a)(c + a) = 2 × 8 = 16so b² = 16 and b = 4 Halve each factor:1 × 4 = 2², and 1 = 1², 4 = 2²n = 1, m = 2
Why b² = (c − a)(c + a). Take a c × c square and cut away an a × a square: the L-shape left over has area c² − a² = b². Swing one arm of the L round and it becomes a rectangle (c − a) wide and (c + a) long. For 3-4-5 that is 2 × 8 = 16 = 4².

Proof of the converse

Take m > n > 0 with no common factor, one even and one odd, and set a = m2 − n2, b = 2mn, c = m2 + n2. It is a triple by algebra. Suppose a prime p divided both a and c. Since c is odd (one odd square plus one even square), p is odd. It divides c + a = 2m2 and c − a = 2n2, so it divides m2 and n2, hence m and n. That contradicts gcd(m, n) = 1. So gcd(a, c) = 1, and by the lemma the triple is primitive.

Why m and n are unique

The proof also tells you how to recover them: m2 = c + a over 2 and n2 = c − a over 2, where a is the odd leg. For 20-21-29 the odd leg is 21, so m2 = 29 + 21 over 2 = 25 and n2 = 29 − 21 over 2 = 4, giving m = 5, n = 2. Check: 2 × 5 × 2 = 20. Different pairs (m, n) therefore always give different primitive triples.

A second, more geometric proof finds all rational points on the circle x2 + y2 = 1 by drawing lines through (−1, 0); it is explained, with an animation, on the Euclid's formula page. A third approach organizes all primitive triples into a family tree; see the tree of primitive Pythagorean triples.

How many primitive triples are there?

Infinitely many. Taking m = n + 1 works for every n ≥ 1, because consecutive numbers share no factor and one of them is even. It produces the endless family (2n + 1,  2n2 + 2n,  2n2 + 2n + 1): 3-4-5, 5-12-13, 7-24-25, 9-40-41 and so on.

Counting them up to a limit shows a striking regularity. The number of primitive triples with hypotenuse at most N is very close to N over 2π, about 0.159 × N:

Hypotenuse up to NPrimitive triplesN ÷ 2π (rounded to 0.1)
1001615.9
1,000158159.2
10,0001,5931,591.5
100,00015,91915,915.5
1,000,000159,139159,154.9
02505007501,00004080120160 number of primitive triples with c ≤ N the line N ÷ 2π N (largest hypotenuse allowed)
Counting primitive triples: each step is one new hypotenuse. Up to c = 1,000 there are 158 of them, and the count stays remarkably close to the straight line N ÷ 2π ≈ 0.159N.

Which numbers are hypotenuses and legs

  • A number c is the hypotenuse of a primitive triple exactly when every prime factor of c leaves remainder 1 when divided by 4. If c has k different prime factors, it is the hypotenuse of exactly 2k − 1 primitive triples. So 5 has one (3-4-5); 65 = 5 × 13 has two (16-63-65 and 33-56-65); and 1105 = 5 × 13 × 17 has four (47-1104-1105, 264-1073-1105, 576-943-1105 and 744-817-1105). This rests on Fermat's theorem on sums of two squares, which we use here without proof.
  • A number is a leg of a primitive triple exactly when it is odd and at least 3, or a multiple of 4. Numbers like 6, 10 and 14, which are 2 more than a multiple of 4, never are. With k different prime factors, such a number is a leg of exactly 2k − 1 primitive triples: 12 = 2² × 3 is a leg of two, 5-12-13 and 12-35-37.

Both rules were checked by computer for every number up to 3,000 (hypotenuses) and 150 (legs). The list of Pythagorean triples shows them in action.

Divisibility properties, with proofs

Throughout, (a, b, c) is primitive, a is odd, b is even, and m, n are its Euclid parameters.

1. The even leg is a multiple of 4

b = 2mn, and one of m, n is even, so b = 2 × (even) is a multiple of 4.

2. Exactly one leg is a multiple of 3, and the hypotenuse never is

A square leaves remainder 0 or 1 when divided by 3 (because (3k ± 1)2 = 9k2 ± 6k + 1). If neither leg were a multiple of 3, then a2 + b2 would leave remainder 1 + 1 = 2, which no square does. Both legs can't be multiples of 3 in a primitive triple, so exactly one is. If 3 divided c, then a2 + b2 would leave remainder 0, which forces both squares to leave remainder 0, so both legs would be multiples of 3; impossible.

3. Exactly one of the three numbers is a multiple of 5

A square leaves remainder 0, 1 or 4 when divided by 5. If neither leg is a multiple of 5, the two squares leave remainders from {1, 4}, and the possible sums are 1 + 1 = 2, 4 + 4 = 8 (remainder 3) and 1 + 4 = 5 (remainder 0). Only the last can be a square, and then c2, hence c, is a multiple of 5. So at least one number is a multiple of 5, and since they are pairwise coprime, exactly one is.

4. Consequences for products and area

Since 4 divides b and 3 divides a leg, ab is a multiple of 12 and the area 1 over 2ab is a multiple of 6. Adding the factor 5 gives: abc is a multiple of 3 × 4 × 5 = 60.

5. The hypotenuse leaves remainder 1 when divided by 4

c = m2 + n2 with one of m, n odd and the other even, so c leaves remainder 1 + 0 = 1.

6. Sums and differences are squares

From the proof, c + a = 2m2 and c − a = 2n2. Also c + b = m2 + 2mn + n2 = (m + n)2 and c − b = (m − n)2. For 20-21-29: 29 − 20 = 9 = 32, 29 + 20 = 49 = 72, 29 − 21 = 8 = 2 × 22 and 29 + 21 = 50 = 2 × 52.

Every primitive triple with c ≤ 100. In each row exactly one number is divisible by 3, by 4 and by 5, c always leaves remainder 1 when divided by 4, and abc is always a multiple of 60.
TripleEven leg÷ 4÷ 3÷ 5c mod 4abc ÷ 60
3-4-5443511
5-12-131212125113
8-15-17881515134
7-24-2524242425170
20-21-29202021201203
12-35-37121212351259
9-40-4140409401246
28-45-532828454511,113
11-60-61606060601671
16-63-651616636511,092
33-56-655656336512,002
48-55-734848485513,212
13-84-858484848511,547
36-77-853636368513,927
39-80-898080398014,628
65-72-977272726517,566

Non-primitive triplesMultiplying by k can only add factors, so every triple keeps the "at least one" versions: an even leg divisible by 4, a leg divisible by 3, a number divisible by 5, area a multiple of 6, and abc a multiple of 60. The "exactly one" and "c is odd" statements can fail: 15-20-25 has three multiples of 5, and 6-8-10 has an even hypotenuse. Parity arguments like these are the same kind that prove √2 is irrational, and Fermat combined them with the theorem above in his proof of the case n = 4 of Fermat's Last Theorem.

Frequently asked questions

Is 6-8-10 a primitive Pythagorean triple?

No. All three numbers are even, so their greatest common divisor is 2. Dividing by 2 gives 3-4-5, which is the primitive triple behind it.

How do you know if a Pythagorean triple is primitive?

Find the greatest common divisor of the two legs. If it is 1, the triple is primitive; otherwise divide all three numbers by it. You never need to check the hypotenuse separately, because in a triple any common factor of two numbers is shared by all three.

Can the hypotenuse of a primitive triple be even?

Never. The legs of a primitive triple are one odd and one even, so c2 is odd and so is c. In fact c is always 1 more than a multiple of 4, such as 5, 13, 17, 25 or 29.

How many primitive Pythagorean triples have hypotenuse under 100?

Sixteen: 3-4-5, 5-12-13, 8-15-17, 7-24-25, 20-21-29, 12-35-37, 9-40-41, 28-45-53, 11-60-61, 16-63-65, 33-56-65, 48-55-73, 13-84-85, 36-77-85, 39-80-89 and 65-72-97.

Can both legs of a primitive triple be prime numbers?

No, because the even leg is always a multiple of 4. The odd leg and the hypotenuse can both be prime, though, as in 3-4-5, 5-12-13, 11-60-61 and 19-180-181.

Sources and further reading

  1. W. Sierpiński, Pythagorean Triangles (1962; Dover reprint, 2003). A whole book of theorems about triples, including the divisibility results above.
  2. G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers (Oxford University Press). The standard reference for sums of two squares.
  3. Pythagorean triple, Wikipedia.
  4. Pythagorean Triple, Wolfram MathWorld.

Keep exploring