Generating Pythagorean Triples Advanced. This lesson goes beyond core Geometry. You can skip it.

Watch the video explainer

Learning goals

  • Reduce a Pythagorean triple to its primitive triple and identify the scale factor
  • Derive and use the formulas that generate Pythagorean triples
  • Explain how parity and coprimality determine whether the formulas give a primitive triple
  • Recover the two parameters of a primitive triple and justify why the recovery works

Reduce a triple to its smallest integer copy

A Pythagorean triple consists of positive integers aa, bb, and cc with

a2+b2=c2.a^2+b^2=c^2.

By the Pythagorean theorem and its converse, these are the lengths of a right triangle, with hypotenuse cc. To see that the lengths make a triangle, build a right corner with legs aa and bb. The third side has positive length cc by the theorem. The two leg entries can go in either order.

A triple is primitive when the greatest common factor (GCF) of its three entries is 11. The triangles below have the same shape. The small one has no common factor greater than 11, and each length of the larger one is three times its partner.

One shape at two sizesThe larger right triangle has every side three times the corresponding side of the smaller one.34591215
One drawing scale for both triangles shows what multiplying each side by three does to the shape.

Multiplying all lengths by a positive integer kk multiplies both sides of the squared equation by k2k^2. Dividing all lengths by their GCF reverses that operation and leaves a primitive triple. The GCF must be removed in full. Any common factor still left in the quotient would give a larger common factor of the original lengths.

Worked example 1 Find the original shape

Problem. A right triangle has side lengths 3636, 105105, and 111111 units. Find its primitive triple and the integer scale factor from the primitive triangle to this triangle.

Solution. The common factors of 3636 and 105105 are 11 and 33. Since 111111 is also divisible by 33, the GCF of all three lengths is 33.

Divide all three entries by 33.

(363,1053,1113)=(12,35,37).\left(\frac{36}{3},\frac{105}{3},\frac{111}{3}\right) =(12,35,37).

The primitive triple is (12,35,37)(12,35,37). The scale factor to the given triangle is 33.

Check your understanding

The right triangle with sides 170170, 264264, and 314314 has which primitive triple?

Answer choices

Build a triple from two squares

A sum and difference can give two sides whose squares differ by a perfect square. Start with 4949 and 44. Their sum is 5353 and their difference is 4545.

Factor the difference of the new squares. In the sum, the 44 terms cancel. In the difference, the 4949 terms cancel.

532−452=(53+45)(53−45)=(2⋅49)(2⋅4)=(2⋅7⋅2)2=282.\begin{aligned} 53^2-45^2&=(53+45)(53-45)\\ &=(2\cdot49)(2\cdot4)\\ &=(2\cdot7\cdot2)^2\\ &=28^2. \end{aligned}

So 4545, 2828, and 5353 are side lengths of a right triangle. The product became a square because both starting numbers were squares.

Why the two-parameter construction gives a right triangle#

Take integers m>n>0m>n>0. Write aa for the difference of their squares and cc for the sum.

a=m2−n2c=m2+n2\begin{aligned} a&=m^2-n^2\\ c&=m^2+n^2 \end{aligned}

Factoring uses the same sums and differences as with 4949 and 44.

c2−a2=(c+a)(c−a)=(2m2)(2n2)=(2mn)2.\begin{aligned} c^2-a^2&=(c+a)(c-a)\\ &=(2m^2)(2n^2)\\ &=(2mn)^2. \end{aligned}

Use 2mn2mn as the remaining leg bb. The factored equation then gives a2+b2=c2a^2+b^2=c^2. All entries are positive because m>n>0m>n>0. The choice of 77 and 22 in the numerical argument only supplied the two squares.

The three entries (m2−n2, 2mn, m2+n2)(m^2-n^2,\ 2mn,\ m^2+n^2) are called Euclid’s formulas. The second entry is always even, but it may be the shorter or the longer leg.

Worked example 2 The even leg comes second

Problem. Generate the triple for the parameter pair (8,3)(8,3). Give the two legs in increasing order and name the hypotenuse.

Solution. The difference gives one leg, the doubled product gives the other, and the sum gives the hypotenuse.

a=64−9a=55b=2⋅8⋅3b=48c=64+9c=73.\begin{aligned} a&=64-9\\ a&=55\\[2pt] b&=2\cdot8\cdot3\\ b&=48\\[2pt] c&=64+9\\ c&=73. \end{aligned}

The legs in increasing order are 4848 and 5555. The hypotenuse is 7373.

Check your understanding

For the parameter pair (10,3)(10,3), which entry equals the hypotenuse?

Answer choices

Tell which parameters give a primitive triple

Some pairs build a triangle whose sides have a common factor. A pair of integers is coprime if its GCF is 11. It has opposite parity if one integer is even and the other is odd.

Worked example 3 Two tests for the inputs

Problem. For each pair below, decide whether the output of Euclid’s formulas is primitive. When it is scaled, find the primitive triple and the scale factor.

Case A uses the parameter pair (5,4)(5,4).

Case B uses the parameter pair (5,3)(5,3).

Case C uses the parameter pair (6,3)(6,3).

Solution. Case A gives (9,40,41)(9,40,41). The GCF of 99 and 4040 is 11, so the triple is primitive. The parameters are coprime and have opposite parity.

Case B gives (16,30,34)(16,30,34). Both parameters are odd, so both the difference and sum of their squares are even. The GCF of all three entries is 22, giving primitive triple (8,15,17)(8,15,17) and scale factor 22.

Case C gives (27,36,45)(27,36,45). Both parameters are multiples of 33, so the formulas use multiples of 323^2. The GCF of the three entries is 99, giving primitive triple (3,4,5)(3,4,5) and scale factor 99.

Compare primitive, same-parity, and shared-factor outputsThree separate to-scale right triangles show how the parameter cases affect the greatest common factor.94041163034273645A. Coprime, one evenGCF 1B. Coprime, both oddGCF 2C. Shared factor 3GCF 9
All three right triangles use the same drawing scale. An even output in every entry reveals the parity case, while a shared factor of three in the parameters supplies nine in every entry.

The formulas give a primitive triple exactly when the parameters are coprime and have opposite parity.

Why coprimality and opposite parity give a primitive triple#

If the parameters share a factor d>1d>1, each formula contains a factor d2d^2, just as 323^2 divided all the outputs in Case C.

If the parameters have the same parity, their square sum and square difference are even. The doubled product is already even, so 22 divides all three outputs.

Now take coprime parameters of opposite parity. For example, with the parameter pair (9,2)(9,2), both 7777 and 8585 are odd, so 22 cannot divide the whole triple. Any odd prime dividing both 7777 and 8585 would divide their sum and difference.

85+77=2⋅8185−77=2⋅4.\begin{aligned} 85+77&=2\cdot81\\ 85-77&=2\cdot4. \end{aligned}

That prime would have to divide both 99 and 22, since it is odd and every prime factor of a square comes from its base. The two parameters are coprime.

For any coprime parameters of opposite parity, aa and cc are odd, and the same sum and difference are 2m22m^2 and 2n22n^2. No odd prime can divide both because that prime would divide both mm and nn. So no prime divides all three outputs, and their GCF is 11.

Check your understanding

Why can the parameter pair (12,9)(12,9) produce a scaled triple even though they have opposite parity?

Answer choices

Recover the parameters of a primitive triple

The formulas can be reversed. For the primitive triple with legs 3333 and 5656 and hypotenuse 6565, use the odd leg for aa and the even leg for bb. The squares we want come from adding and subtracting the odd leg.

65+332=4965−332=16.\begin{aligned} \frac{65+33}{2}&=49\\ \frac{65-33}{2}&=16. \end{aligned}

The two results are positive and coprime. Their product is (56/2)2(56/2)^2, a square. Since a prime can appear in at most one of the two factors, each factor must contain its own primes in pairs. Here 4949 contains two copies of 77, and 1616 contains four copies of 22. Taking positive square roots gives 77 and 44, which are coprime and have opposite parity.

Recover the square parameters in two branchesThe same two sides supply both branches. The even leg is used to show that the two intermediate results multiply to a square.Hypotenuse 65Odd leg 33(65 + 33) ÷ 249(65 − 33) ÷ 216Square root7Square root4
Adding the odd leg to the hypotenuse gives twice the larger square. Subtracting the same leg gives twice the smaller one.

Why every primitive triple has these parameters#

A primitive triple has exactly one even leg. Two even legs would make c2c^2 even and hence cc even, giving a common factor of 22. Two odd legs would make c2c^2 leave remainder 22 on division by 44. A square has remainder 00 or 11: an even square is divisible by 44, and an odd square has the form 4t(t+1)+14t(t+1)+1 for some integer tt. With one odd and one even leg, c2c^2 is odd, so cc is odd.

Name the odd leg aa and the even leg bb. Define the positive integers

u=c+a2v=c−a2.\begin{aligned} u&=\frac{c+a}{2}\\ v&=\frac{c-a}{2}. \end{aligned}

Both are integers since aa and cc are odd, and u>v>0u>v>0 since c>a>0c>a>0. Factoring the difference of squares gives

uv=(c+a)(c−a)4=c2−a24=(b2)2.\begin{aligned} uv&=\frac{(c+a)(c-a)}{4}\\ &=\frac{c^2-a^2}{4}\\ &=\left(\frac b2\right)^2. \end{aligned}

Any prime shared by uu and vv would divide their sum cc and their difference aa. It would then divide b2b^2, since b2=c2−a2b^2=c^2-a^2, and so divide bb as well. Primitivity excludes any such prime.

Because uvuv is a square, every prime in its factorization occurs an even number of times. Since uu and vv share no primes, those even counts already occur in each factor separately. The factors are the squares of positive integers mm and nn, respectively, with m>nm>n. A shared prime of mm and nn would also be shared by uu and vv, so mm and nn are coprime. Their squares add to the odd integer cc, which means mm and nn have opposite parity.

Add and subtract the two squares to recover cc and aa. Take the positive square root of uvuv to recover half of bb.

c=m2+n2a=m2−n2b=2mn.\begin{aligned} c&=m^2+n^2\\ a&=m^2-n^2\\ b&=2mn. \end{aligned}

The argument used the same sum, difference and prime-pairing steps as the numerical example. The odd leg and hypotenuse determine uu and vv, so they also determine the unique positive parameters with m>nm>n.

Worked example 4 Recover a pair from an even leg listed first

Problem. The primitive triple is (60,11,61)(60,11,61). Find the positive integers m>nm>n in Euclid’s formulas and use them to check the even leg.

Solution. Use 1111 as the odd leg and 6161 as the hypotenuse.

m2=61+112=36n2=61−112=25.\begin{aligned} m^2&=\frac{61+11}{2}\\ &=36\\[2pt] n^2&=\frac{61-11}{2}\\ &=25. \end{aligned}

Taking positive roots gives the parameter pair (6,5)(6,5). The even leg checks because

2⋅6⋅5=60.2\cdot6\cdot5=60.

Check your understanding

For the primitive triple with legs 2020 and 9999 and hypotenuse 101101, which pair gives the parameters (m,n)(m,n)?

Answer choices

Separate the scale factor from the parameters

For any Pythagorean triple, divide by the GCF first. The quotient is primitive, so it has a unique pair of coprime, opposite-parity parameters. Then multiply the three generated entries by the original GCF kk to recover the given triple. Leg order can be swapped.

Worked example 5 Recover both the scale and the shape

Problem. A right triangle has sides 132132, 351351, and 375375 units. Find its integer scale factor from the primitive triangle, and find the parameters of that primitive triple.

Solution. The GCF of 132132 and 351351 is 33. Since 375375 is divisible by 33, the GCF of all three is 33. Dividing gives primitive triple (44,117,125)(44,117,125).

Use the odd leg 117117 and the hypotenuse 125125.

m2=125+1172=121n2=125−1172=4.\begin{aligned} m^2&=\frac{125+117}{2}\\ &=121\\[2pt] n^2&=\frac{125-117}{2}\\ &=4. \end{aligned}

The parameters are 1111 and 22. Their doubled product is 4444, which matches the even leg of the primitive triple. The original triangle uses scale factor 33.

Check your understanding

A right triangle has sides 5050, 624624, and 626626. Why should you divide by the GCF before recovering primitive parameters?

Answer choices

Common mistakes

Practice

Multiple Choice Questions (MCQ)

Progressively harder sets of questions. Each opens on its own page.

Core practice

Practice problems at the level of the course, to be worked out on paper. Hints one at a time, then the answer or the full worked solution, with your progress kept in this browser.

Core practice Work it out on paper 10 problems Start →
More resources (optional)

Other explanations of this lesson, if you want a second take.

A bit of history (optional)

A clay tablet now in Columbia University’s collection has rows of numbers pressed into it in cuneiform. In the early 1940s, historians Otto Neugebauer and Abraham Sachs interpreted the numbers on the tablet, known as Plimpton 322, as a record of what we call Pythagorean triples. That made the tablet evidence of knowledge about these triples long before Pythagoras.

The rows still leave room for a historical question. What job did this table do? Historian Eleanor Robson proposed that it was a teacher’s aid for preparing problems involving right triangles and pairs of numbers whose product is one. The surviving table preserves the numbers, while its purpose remains a matter of interpretation. Columbia University Libraries’ exhibition on Plimpton 322.

Your progress

See all your progress →